Results 1 to 4 of 4
- 06-13-2008, 03:15 PM #1
Member
- Join Date
- Jun 2008
- Posts
- 48
- Rep Power
- 0
who to take user input ,not by console...
pls send me a simple example for taking user input which should be used in other calss ..
- i suppose it will not be possible to take that input in one other meyhod except main() . i think it only be possible by System.in.readline().
Help me its urgent.... give me very simple example
- 06-13-2008, 03:25 PM #2
The returns what the user typed as though one had codedJava Code:System.in.read();
People are going to laugh at me for the cast, it is an auto-conversion, all widening conversions are implicit generally.Java Code:int anInt = (int)'c';//
System.in.read(); will not continue operation of the Java Virtual Machine until the user types something. I try to use a simple file and do reading from that. There is a Scanner class that is popular for reading System.in but that may not be what you need.
Are you just trying to get going?
- 06-13-2008, 03:42 PM #3
Member
- Join Date
- Jun 2008
- Posts
- 48
- Rep Power
- 0
import java.lang.*;
public class ctruct
{
public static void main(String args[])
{
String ename;
System.out.println("Enter emp name");
ename=System.in.readline();
System.out.println("Enter emp name -->"+ename);
}
}
this is the lay man code .. i will learn scanner class later .. 2 -3 yrs back i use to take i/p by system.in.readln() or somthing like that..
- 06-13-2008, 10:09 PM #4
It is difficult to decipher your qestion. I tried to reply earlier when you posted but the cgi would not propagate your second post.
Is having another class written to work with the readline(); what you are trying to grasp?Java Code:// maybe this is what poster asking class FirstClass{ public static void main(String[] args){ SecondClass s = new SecondClass(); String t = System.in.readline();// or scanner s.doSomething(t);
Similar Threads
-
How to get input from Console
By karma in forum New To JavaReplies: 8Last Post: 08-13-2010, 09:32 PM -
how to get input from User
By Alvaro in forum New To JavaReplies: 7Last Post: 01-15-2010, 11:02 PM -
how to take input from console in jsp
By veena in forum New To JavaReplies: 1Last Post: 05-06-2008, 04:39 AM -
cant take input from user
By new_1 in forum New To JavaReplies: 6Last Post: 12-25-2007, 07:38 AM -
Taking input from console
By Java Tip in forum Java TipReplies: 0Last Post: 11-05-2007, 04:47 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks