Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Plz help i am a newbie

 
Tirthankar Mukherjee
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
vignesh hariharan
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic