Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


how can i take the inputs from users in java program?

Answers were Sorted based on User's Feedback



how can i take the inputs from users in java program?..

Answer / dilshad

there r 2 ways to give the input ,


one is from command-line argument at run time.......


and the another one is to use readLine method of
DataInputStream class.............

Is This Answer Correct ?    33 Yes 1 No

how can i take the inputs from users in java program?..

Answer / mohammad faisal

There are two methods to input a text in java.
The first one is through command line arguments.
i.e.,At the run-time we have to pass all the inputs.
But there is a problem to the user of the program because
he is unable to get the order of the inputs.
Therefore a programmer must have to prefer the readLine
method.
The readLine method can be implemented like:
//1st method
import java.io.*;
class Program
{
public static void main(String args[])
{
String str="";
BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));
System.out.print("Enter your name: ");
str=br.readLine();
System.out.print("You have entered: "+str);
}
}

//2nd method
import java.util.*;
class Program
{
public static void main(String args[])
{
String str="";
Scanner s=new Scanner(System.in);
//works in jdk 5&above
System.out.print("Enter your name: ");
str=s.next();
System.out.print("You entered: "+str);
}
}

Is This Answer Correct ?    18 Yes 0 No

how can i take the inputs from users in java program?..

Answer / archana

through the 1.command line arguments or trough 2.datainput
stream

Is This Answer Correct ?    8 Yes 1 No

how can i take the inputs from users in java program?..

Answer / harish189

1.DataInputStream Reader
2.BufferedInputStream Reader

Is This Answer Correct ?    6 Yes 0 No

how can i take the inputs from users in java program?..

Answer / prashant

With the help of Scanner class.

Is This Answer Correct ?    2 Yes 0 No

how can i take the inputs from users in java program?..

Answer / priyanka

int a;
a=Integer.parseInt(cin.readLine());

Is This Answer Correct ?    7 Yes 7 No

how can i take the inputs from users in java program?..

Answer / desai.ankita0422@gmail.com

using Scanner with next function

Is This Answer Correct ?    0 Yes 2 No

Post New Answer

More Core Java Interview Questions

Can inner class final?

0 Answers  


If I have 1000 objects and my requirement is to sort them quickly, then which collection would you recommend and why?

5 Answers   KPIT,


How do you check if a character in a string is a digit or letter?

0 Answers  


class A{ some variables; public void a()throws Excepion1,Exception2{....} } class B extends A{ variables... public void a()throws E2,E3{.....} } Qns: here override of methods occurs or not,ore else wil give any compilation error or run properly..plz tell me briefly whts happening with the above codes....

4 Answers   Quinnox,


What is immutable in java?

0 Answers  


Static Variable can referred in non-static method?

3 Answers  


What is the importance of finally block in exception handling?

0 Answers  


What’s the difference between the methods sleep() and wait()?

0 Answers  


what is the difference between a java object reference and c++ pointer?

4 Answers  


What is the use of http-tunneling in rmi?

0 Answers  


Howto get an object that will perform date & time calculations then format it for output in some different locales with different date style.can ne1 tel me the answer of this question.pls

0 Answers  


How many threads does a core java have?

0 Answers  


Categories