Results 1 to 2 of 2
  1. #1
    vichet is offline Member
    Join Date
    Apr 2008
    Rep Power

    Default why we use public access modifier?

    I have a slight problem with my code below. I created a file and named it and wrote all code into the file.

    My code below wont be compiled. unless I add an access modifier public. and I do not understand why i need to do that.

    PHP Code:
    package classs.and.objects;
    public interface ClosedCurve {
    	double computeArea();
    class Triangle implements ClosedCurve {
    	double computeArea() // I need to change to public double computeArea()
    		return 0.0;

  2. #2
    sanjeevtarar's Avatar
    sanjeevtarar is offline Senior Member
    Join Date
    Apr 2008
    Rep Power


    Hi ..

    Because in interface methods are public abstract default.
    and in your class if u are not providing public access modifiers then default access modifier is used and it is not possible to decree the access modifiers from public to default in java.

    if still not clear the i will let u know more.


Similar Threads

  1. public declaration ('undeclaring')
    By Jadellll in forum New To Java
    Replies: 2
    Last Post: 03-17-2008, 09:50 PM
  2. Public Holidays (Australia)
    By oranjeBoven in forum Advanced Java
    Replies: 0
    Last Post: 02-13-2008, 09:14 AM
  3. Public class variable
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-03-2007, 10:58 AM
  4. public method
    By dirtycash in forum New To Java
    Replies: 4
    Last Post: 11-21-2007, 08:29 PM
  5. Replies: 1
    Last Post: 08-07-2007, 08:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts