cannot find symbol In.getInt

cannot find symbol In.getInt

Page 1 of 1

3 Replies - 2804 Views - Last Post: 19 April 2010 - 03:46 AM Rate Topic: -----

#1 dusker  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 05-September 06

cannot find symbol In.getInt

Posted 05 September 2006 - 09:38 PM

Now, I copied this code out of the text word for word because our class is just starting to learn to use these and this was an example question using In.getInt and all of those. Well, I have tried using in.getInt(); and In.getInt(); but I continually get :

Interactive.java:19: cannot find symbol
symbol : variable in
location: class interactive
String familyName = In.getString();

and it does that for all the In.get.... that I type, I really have no idea, sorry I'm really beginner at this.
^



public class Interactive
{		
	public static void main(String[] args)
	{
		//Obtain name and age
		System.out.println("What is your first initial?");
		char firstInitial = in.getChar();
		System.out.println("What is your family name?");
		String familyName = in.getString();
		System.out.println("What is your age in years?");
		int age = in.getInt();
		
		// respond to input
		System.out.println("Well, " + firstInitial + ". "
			+ familyName + " - "
			+ "I see that your age is " +age);
		}
}



Is This A Good Question/Topic? 0
  • +

Replies To: cannot find symbol In.getInt

#2 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: cannot find symbol In.getInt

Posted 05 September 2006 - 11:02 PM

The problem is that you have not defined in, and the methods you are using are from the ByteBuffer class.

You need to define a ByteBuffer object and call it in. Also make sure you have the necassary import for the ByteBuffer class.
import java.nio.*;

//declare inside your main
ByteBuffer in = ByteBuffer.allocate(14);


Once declared the getChar and getInt methods will be valid. Not sure what class uses the getString method. But it will not work with the ByteBuffer object.

You can find the API for the ByteBuffer class here.
Was This Post Helpful? 0
  • +
  • -

#3 Guest_Kdog*


Reputation:

Re: cannot find symbol In.getInt

Posted 18 April 2010 - 05:59 PM

the problem is not what you are typing in.getInt its on what computer you are doing it on

The in.get command is actually a compiled java class that was made to make it easier to get user input from a keyboard. in.get allows you to do in one line what a buffered reader usually does in about 4 lines. but the In.get class has to already exist in your computer otherwise you have to do it the long way around which is usually by buffering the data in from the keyboard, and the parsing or trimming.

You should ask you teacher or instructor for a copy of the in class to put on your computer.
Was This Post Helpful? -1

#4 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2872
  • View blog
  • Posts: 11,031
  • Joined: 15-July 08

Re: cannot find symbol In.getInt

Posted 19 April 2010 - 03:46 AM

Didn't mean to "-" that, but please avoid necroing super old topics like this one. Thank you.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1