• Post Reply Bookmark Topic Watch Topic
  • New Topic

what is wrong in this code

 
lp
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import java.io.*;
import java.util.*;
public class l1
{
public static void main(String [] args)
{
System.out.println("enter a value");
DataInputStream did =new DataInputStream(System.in);
System.out.println("lakshmipanda"+ did );
}
}
 
Maciej Kolodziej
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But what do You want to do?
I can tell You what are You doing now. You created new DataInputStream attached to standard input. Than You printed dis.toString() which in this case is just class name and reference number.
 
lp
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Actually the doubt i had was when i run this code i am getting an abstartc value and not the values entered .so i wanted to know incase i want to assign the input value to an integer format i have to parse the 'did' value ,but still mycode is giving me errors please help me in clearing this doubt
 
netharam ram
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import java.io.*;
import java.util.*;
public class l1
{
public static void main(String [] args)
{
try
{
byte[] data=new byte[50];
System.out.println("enter a value");
DataInputStream did =new DataInputStream(System.in);
did.read(data);
System.out.println("lakshmipanda " + new String(data) );
}catch(Exception e){System.out.println(e);}
}
}
Try this out.
Happy middling with java.
Netharam.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!