Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Error concerning cannot find symbol method Integer.parseInt(java.lang.Strin

630556Dec 19 2008 — edited Dec 20 2008
I am using a scanner, and i wanted to make sure that the user was inputting the correct data types. I also wanted to cut down on code reuse. So i have a couple of methods fir the inputs
	private String inputString(String prompt) { 
	    
		System.out.println(prompt);     
		return input.next();
	}
	
	private int inputInt(String prompt) {     
	
	int val = -1;     
		for(;;) 
		{          
		System.out.println(prompt);          
			try {               
				val = Integer.parseInteger(input.next());               
				break;          
				} 
			catch (Exception ex) {               
				System.out.println("Invalid value, please try again.");          
				}     
		}     
	return val;
	}
	
	public void addUser(int choice)
	{
		
		if(choice==1)
		{
			String title = inputString("Please enter your title ");
			int studentId = inputInt("Please enter your Student ID ");
					
			StudentBorrower studentBor = new StudentBorrower(title, studentId);
			libraryUsers[x]=studentBor;
			x++;
		}
The problem at the moment is that i am receiving the error cannot find symbol method Integer.parseInt(java.lang.String)
I am not sure why i am getting this error, do i need to import a library besides scanner? Is someone able to explain why i might be getting this error?
thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 17 2009
Added on Dec 19 2008
4 comments
1,125 views