wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Plz help i am a newbie Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Plz help i am a newbie" Watch "Plz help i am a newbie" New topic
Author

Plz help i am a newbie

Tirthankar Mukherjee
Ranch Hand

Joined: Apr 08, 2006
Posts: 51
import java.io.DataInputStream;

class CalculateAccnDist
{
public static void main(String args[])
{
DataInputStream in = new DataInputStream(System.in);
float a=0.0f;
float u=0.0f;

try
{
System.out.println("Enter the initial speed in m/sec :");
u=Float.valueOf(in.readLine()).floatValue();
System.out.println("Enter the acceleration of the body :");
a=Float.valueOf(in.readLine()).floatValue();
}
catch (Exception e) { }
System.out.println(" Time(s) Distance(m)");
for(int t=0;t<=60;t=t+10)
{
System.out.println(t + ((u*t) + ((a*t*t)/2)));
}
}
}

/* In this above java prog. there is a compiler error,saying :
Note: D:\j2sdk1.4.2_11\bin\CalculateAccnDist.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details.

why ??
plz hwlp mwe I am a newbie
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41083
    
  43
That's not an error - it's a warning. The class file should have been created regardless. It tells you that the DataInputStream.readLine method should no longer be used - it is obsolete. The reason, and what to use instead, are outlined in the javadocs for that method.


Ping & DNS - my free Android networking tools app
vignesh hariharan
Ranch Hand

Joined: Jun 23, 2005
Posts: 77
yes.. DataInputStream is an older version of the InputStreams...but still it can be used. but it is better you can replace it with

BufferedReader inp=new BufferedReader(new InputStreamReader(System.in));

now if u use this inp object in your program then the warning messege which u encountered will not be found..


Regards,
vignesh
 
Consider Paul's rocket mass heater.
 
subject: Plz help i am a newbie
 
Similar Threads
deprecated API
parseFloat and Float.NaN??
Exception Handling
JQ+ and confusion with try/catch/finally
Doubt in try - catch - finally block