Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Error Handling in Access Modifiers

  1. #1
    Junior Member
    Join Date
    Mar 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Error Handling in Access Modifiers

    How do I try ... catch an error produced by access modifiers? Say for instance

    class A{  
    private void message(){System.out.println("Hello java");}  
    }  
     
    public class Simple{  
     public static void main(String args[]){  
       A obj=new A();  
       obj.message();//Compile Time Error  
       }  
    }
    Last edited by Ralf17; July 4th, 2019 at 07:53 AM.

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Error Handling in Access Modifiers

    try{} catch is for a program's execution, NOT for compilation.
    See the tutorial: https://docs.oracle.com/javase/tutor...ons/index.html

    Please edit your post and wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Mar 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Error Handling in Access Modifiers

    Yeah, I already got it beforehand with the help of a friend. Anyway, thanks for your reply!

Similar Threads

  1. modifiers for variable
    By ashl7 in forum What's Wrong With My Code?
    Replies: 10
    Last Post: April 11th, 2013, 06:17 AM
  2. declared with the wrong access modifiers ?????????????????????????????
    By cosmickinect in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 12th, 2013, 06:57 AM
  3. [SOLVED] MS Access Error: Too Few Parameters. Expected 2?
    By Kimiko Sakaki in forum What's Wrong With My Code?
    Replies: 5
    Last Post: June 13th, 2012, 08:31 PM
  4. about access modifiers (abstract and protected)
    By Satyanvesh in forum Java Theory & Questions
    Replies: 12
    Last Post: February 2nd, 2012, 12:43 AM
  5. [SOLVED] Handling Errors / calling Error-Catching Methods
    By movsesinator in forum Object Oriented Programming
    Replies: 4
    Last Post: April 6th, 2010, 05:35 AM

Tags for this Thread