Here is my code
import java.io.*;
class Add { public static void main (String args[] ) throws IOException; { BufferedReader br=new BufferedReader( new InputStreamReader (System.in)); System.out.println("Enter the value of X:"); int x=Integer.parseInt(br.readLine());
System.out.println("Enter the Value of Y:"); int y=Integer.parseInt(br.readLine());
int z=x+y; System.out.println("\n\nValue of X + Y = " +z);
}
}
when i try to compile in command prompt.
first i have to set the path. then i typed javac Add.java
then it says
javac : file is not found : add. java Usage : javac
please help me. if anyone can explain whats going on. im a mega noob in java. help me
I assume you called your file Add.java, right? I get a different error when I try to compile your code. Are you sure you didn't make a typo and you have your path set correctly? Try this. Create a new file called helloworld.java and put this in it:
public class helloworld
{
public static void main()
{
System.out.println("Hello World");
}
}
Then at the command line type "
javac helloworld.java
then
java helloworld
You should get no errors and the screen should display "Hello World". Your error looks like a simple typo possibly.