File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes i need help on java method please Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "i need help on java method please" Watch "i need help on java method please" New topic
Author

i need help on java method please

brando brandido
Greenhorn

Joined: Jan 11, 2012
Posts: 20
hello,

i am a bit confuse with the output of my code

this is my text file


and this is my java code



The objective of this code is to get the employee id of employees and then display employee details.

e.g. you type an employee id 2006-0031

the code will then read the text file and when that employee id is found, it then display the name of employees and other details such as employee name, base pay, net pay.

The problem with my code is that when i type the employee id 2001-0001 it displays the output correctly
but when i type an employee id 2006-0031 or 2010-0008 i will get an error.

What is wrong with my code? what is the correct coding?
Niraj Jha
Ranch Hand

Joined: Feb 20, 2013
Posts: 61

It is because of calling readLine() method three times(Line number 14 , 27, 29 on br).Call it once and match your condition.......
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36453
    
  15
Why are all your methods static?
brando brandido
Greenhorn

Joined: Jan 11, 2012
Posts: 20
Niraj Jha wrote:It is because of calling readLine() method three times(Line number 14 , 27, 29 on br).Call it once and match your condition.......


ok i have changed it to



and now i can get the first employee id when i input 2006-0031

but then the 2nd and 3rd it displays 'no employee records!'
brando brandido
Greenhorn

Joined: Jan 11, 2012
Posts: 20
Campbell Ritchie wrote:Why are all your methods static?


The instructions is use three methods and so therefore that what i did. Please correct me, i am beginner to java. I am willing to learn.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36453
    
  15
I think it is always bad when people hand out assessments telling students how many methods to use.
But that does not explain why you have made all your methods static.
 
 
subject: i need help on java method please
 
Similar Threads
help solving dynamic method invocation exception.
life/death?
about super key
Reading key/value pairs from a .properties file and creating objects
NullPointerException at Java.util.StringTokenizer