Link to home
Start Free TrialLog in
Avatar of gudii9
gudii9Flag for United States of America

asked on

some methods private some are not

Hi,

I was going through below link

http://www.homeandlearn.co.uk/java/more_class_methods.html

I wonder why getGrade() method is private and other methods are not private.

As it is private getGrade() is being called by separate method examGrade() method using this.getGrade ()

I feel it is bit round about approach.

i was not able to copy source code to run. How do i copy and then paste to eclipse?

please advise
Avatar of gurpsbassi
gurpsbassi
Flag of United Kingdom of Great Britain and Northern Ireland image

As soon as I read the title I knew this was a gudii9 question.
SOLUTION
Avatar of gurpsbassi
gurpsbassi
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of phoffric
phoffric

>>  How do i copy and then paste to eclipse
Much of the code on this site are pictures. In IE, right-clicking on the code gives a popup, and one of the options is Save Picture As. You can copy some of the code, such as:
String examGrade(int aScore) {

Exam_Grade = this.getGrade( aScore) ;
return Exam_Grade;
}
>> I wonder why getGrade() method is private and other methods are not private.
>> I feel it is bit round about approach.

I think they are just trying to introduce topics in a haphazard round about approach. I wouldn't make too much of it nor try to use their teaching style as a guideline on good design practices. Their point is:
Notice that this method is private. Just like field variables, making a method private means it can only be seen inside of this class. It can't be seen by the ExamDetails class.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>> i was not able to copy source code to run
If you want to master a language, then I suggest that you type a sample program in and deal with your typos by trying to understand the sometimes cryptic error messages that you get. Learning how to debug a program on your own without bothering your colleagues in the workplace is one of the important steps in becoming a professional. Tracking down the cause of the error message will also force you to think a bit more about what you typed in.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gudii9

ASKER

thank you for the links. I will explore them