i am new please guide me how can i take input from user in java. i did java from lot of time ago now i am starting learn again i did learn take input from user by this, there is a statement to write input from user

first we initialize variable like :

int num;

that we learn to take input like this:

num=MyInput.readInt();

all work in My class: class Circle

what is wrong there i don't understand what is my mistake to take input from user i have search from google but still i could not find please help me
Help me to resolve this error
When i compile bellow program in JDK1.7 there is error: Can not find symbol num=MyInput.readInt();
i don't understand what is this and why i am getting this error help me i am waiting for your response

This is my Program:

public class Circle
{
public static void main(String[] args)throws Exception
{
int num;
System.out.println("Enter a number between 10 and 20:-");
num=MyInput.readInt();

if(num>10 && num<20)
{System.out.println("You have entered a valid number");}

else
{System.out.println("The number you entered is not a valid number");}

}
}

Recommended Answers

All 4 Replies

You missed out the line where you declare and initialse myInput

My Problem is solve by saving MyInput.java file in same folder thank you to all

Solution: To use MyInput class you should copy MyInput.class in the same folder where u saved your file,

or learn how the import statements work. your problem was that the MyInput class was not in the same package as your main class, and you didn't provide any information to your application, that added your MyInput class to the scope of your application.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.