0
This is my program and it is not working
import java.io.*; class sample { public static void main (String [] args) { DataInputStream dis = new DataInputStream (System.in); int radius; radius = dis.readline(); radius = Integer parseInt (dis.readline()); System .out .println (radius ) } }
2 Answers
+ 5
@Azdren Spaces don't matter unless it's separating the identifier/keyword from itself.
There's quite a few errors here.
1)
just use: radius = dis.readInt();
or
Parse it when reading the line.
2)
using DataInputStreamer must be surrounded in try catch, do one of the following:
try{
radius = .....;
}
catch(IOException)
{
}
or
Throw the exception after your main.
3)
You missed a semi-colon after your println.
I suggest using what @Azdren suggested, or maybe a Scanner for System.in reading.
0
thank you for answer the real reason behind this is we have to use IOException in the place after "public static void main (String [] args IOException.". this is the right way. we can also use scanner. but this is oldest method work exclusively for Java 1.2 thank you for the answers