This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes Private method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Private method" Watch "Private method" New topic
Author

Private method

Zachary T. Anderson
Greenhorn

Joined: Mar 12, 2013
Posts: 16
I am not getting any errors code but I know it is not right. First how do I return an ArrayList index of grade and be able to call it from another method. Second the Grade class is a second file that it is calling the grade from, so am I doing that part right. I don't even know how to test to see if it is call the date from the Grade class.

fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11250
    
  16

how do I return an ArrayList index of grade

did you check the API? Maybe there is some way to get the index of an object in an ArrayList

and be able to call it from another method.

What do you mean "call it from another method"? Call what exactly?

Grade class is a second file that it is calling the grade from, so am I doing that part right.

umm...again, I'm not sure what you are asking here.

Part of the problem is that we are not seeing all your code. There are variables being used here that are not declared in what you posted, so it is impossible to really follow what is going on.

Note that I am not asking you to paste 500 lines of code in here...but you need to post enough that we can make sense of what you are doing.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Zachary T. Anderson
Greenhorn

Joined: Mar 12, 2013
Posts: 16
I will look at the API about indexing the ArrayList. Once I get that looked at then maybe it will help me with the other parts so I don't have to paste parts of the code. As to the files Grade is a second class in a separate file and I am writing the code in the Student class. I will also need to call this method into another method that will allow me to remove the grade based on a date. That is why I wanted to know how to call it.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11250
    
  16

If it is a private method, you can't call it from another class. That's kind of what private means.
Zachary T. Anderson
Greenhorn

Joined: Mar 12, 2013
Posts: 16
That what I thought about the private method. The instructions say to make it a private method. Then we have to use what is found in the ArrayList in another part of the program.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Zachary T. Anderson wrote:That what I thought about the private method. The instructions say to make it a private method. Then we have to use what is found in the ArrayList in another part of the program.


Then either:

A) The instructions are faulty, by virtue of being impossible to implement, or at least by being ambiguous.
or
B) You are misunderstanding some nuance of the instructions.

If you paste in the exact, complete instructions, somebody here can probably tell you which, and help clarify any ambiguity in the instructions or misunderstanding on your part.

For example, it might be that one or more public methods are meant to use that private method in their execution.
Zachary T. Anderson
Greenhorn

Joined: Mar 12, 2013
Posts: 16
I was reading it wrong. I took a look again and broken the problem down so that I worked on piece by piece. It is a private method and I don't call it any where else.
 
jQuery in Action, 2nd edition
 
subject: Private method