• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Plz help i am a newbie

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..
 
Put a gun against his head, pulled my trigger, now he's dead, that tiny ad sure bled
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic