Home Answers Viewqa Java-Beginners 14499-Input- Input / Output in Easiest Method in Java

 
 


Basumitra Mitra
Input / Output in Easiest Method in Java
1 Answer(s)      2 years and 5 months ago
Posted in : Java Beginners

How to input from keyboard, both strings and characters and display the result on the screen with the easiest method in Java?

View Answers

December 20, 2010 at 11:52 AM


Hi Friend,

Try the following code:

import java.util.*;

public class ReadFromConsole {
  public static void main(String[] args)throws Exception{
    Scanner input=new Scanner(System.in);
    System.out.println("Enter a Character:");
    int i=System.in.read();
    char ch=(char)i;
    System.out.println("Enter an Integer:");
    int num=input.nextInt();
    System.out.println("Enter String:");
    String st=input.next();
    System.out.println("Character is: "+ch);
    System.out.println("Number is: "+num);
    System.out.println("String is: "+st);
    }
}

Thanks









Related Pages:
Input / Output in Easiest Method in Java
Input / Output in Easiest Method in Java  How to input from keyboard... with the easiest method in Java?   Hi Friend, Try the following code: import...)throws Exception{ Scanner input=new Scanner(System.in
input output
Input And Output       Introduction The Java I/O means Java Input/Output and is a part... class supports the read() and readLine() method for input text from
Input And Output
Input And Output       Introduction The Java I/O means Java Input/Output and is a part of java.io... class supports the read() and readLine() method for input text from a character
input output
input output  java program using fileinputstream and fileoutputstream   Hi Friend, Try the following code: import java.io.*; class FileInputStreamAndFileOutputStream { public static void main(String[] args
input output
input output  java program using fileinputstream and fileoutputstream   Hi Friend, Try the following code: import java.io.*; class FileInputStreamAndFileOutputStream { public static void main(String[] args
input output in java
input output in java  java program using filereader and filewriter   Hi Friend, Try the following code: import java.io.*; class FileInputStreamAndFileOutputStream { public static void main(String[] args) throws
Data input & output Stream
Data input & output Stream  Explain Data Input Stream and Data Output... stream lets an application read primitive Java data types from an underlying input... write primitive Java data types to an output stream in a portable way
Input and Output package
Input and Output package  Hi guys, My professor used input and output... she used in.readint() out.writeln() commands to read input and print output. she created two new objects directly to use this statements. /* input and output
Input and Output problems - Java Beginners
Input and Output problems  1) what is Difference between... to a particular platform. Thus, this class reads characters from a byte input stream.... This link will help you. http://www.roseindia.net/java/beginners
Dialog and Console Input-Output
Prev: Dialog Box Output | Next: Example: Captitalize Java NotesDialog and Console Input-Output  This is similar to the previous program, but it also gets input from the user. 1 2 3 4 5 6 7 8
Java Input/Output Examples
Java Input/Output Examples In this tutorial you will learn about how the Inputs and outputs are managed in java. To understand the Java Input & Output... and interfaces to handle the system input & output through data streams
Working With File,Java Input,Java Input Output,Java Inputstream,Java io Tutorial,Java io package,Java io example
file shown in the table.  Method  Description...; Output of the Program C:\nisha>javac CreateFile1.java C:\nisha>java CreateFile1 New file "myfile.txt" has been created
input
input  a java program that will exchange the last names of two students that were input by a user
output
output  Sir,I am experiencing some problems with the output of this program.I got some useful help this website,but the output of the program isn't producing what it should.let me explain the output below is what happen when
Dialog Box Input Loop
Prev: Example: Capitalize | Next: Java NotesDialog Box Input Loop Indicating end of input with cancel or close box, a special value, or empty input When reading input in a loop user must have some way of indicating that the end
Java get User Input
Java get User Input       In this section, you will learn how to get the user input from... input. The br.readline() method reads the name from the command line. After
output java - Java Beginners
; } a. what is the output of the ff. java statement:? i. System.out.println (secret(5)); ii. System.out.println (2*secret(6)); b.What does the method secret do...output java  public static int secret(int one) { int i; int
Java Command Line Input
Java Command Line Input  How to get input from command line in java... this code you will find the output as Please Input A Number 2 data is- 2... System.out.println("Please Input A Number"); BufferedReader br
different type input in java
type of input method. thank   Java Read through DataInputStream: import...); } }   Java read input through Scanner: import java.util.*; class...); } }   Java read input through BufferedReader import java.io.*; public class
Java User Input
Java User Input  I am using Scanner class for user Input. Scanner s = new Scanner(System.in); String name = s.next(); but i am unable to store full... nextLine() method of Scanner class
Command Line Standard Input In Java
Command Line Standard Input In Java In this section we will discuss about the Java IO Standard Input through Command Line. Standard streams, feature of various O/S, are read through standard input in Java. Standard streams are read
Formatted Output
Java NotesFormatted Output Java 5 implements formatted output with printf.... Taming Tiger: Formatted output Some simple examples format(). Amazingly, there was no built-in way to right justify numbers in Java until Java 5. You had to use
Console Input-Output (Java 5)
Java NotesConsole Input-Output (Java 5) Java 5's java.util.Scanner class... input. System.out.println("What's your name, Earthling?"); name... output System.out.println("Take me to your leader, " + name
java user input - Java Beginners
java user input  how to input from keyboard? please give a example.  Hi Friend, There are lot of ways to input data from keyboard.You... and their methods. *******Use BufferedReader class in main method in following way
Output of null value
Java Factorial Program  I want to create a factorial program in Java...(str); } } Output value Null Description:- In the given example, We have created a class named Nulloutput.In the main method, we have declared
Input From Console
Input From Console     ... and implements flushable interface. The Input from Console is used to access the character -based console device associated with the current Java virtual machine
counting the values in input file and and writing the output to a file
counting the values in input file and and writing the output to a file ... it should write the output to a file. Input file has 20 rows and 4 columns. If we...-code/16483-counting-values-input-file-writing-output-file.html this code
Console Output
Java NotesConsole Output You can write programs that write text lines... for simple input/output, use dialog boxes (see Dialog Box Output). 1 2 3... a similar print method which writes output to the console, but doesn't start
Simple input application in Echo3
Simple input application in Echo3   ... an application which contains the window from where the user can  input... created two java files InputTextServlet.java and InputTextApp.java. InputTextApp
servlets output to jsp - JSP-Servlet
servlets output to jsp  hey i have writing a code lately and wanted to print the output to the jsp page from the servlet.the servlet would read the command prompt n thn return the output as string to the jsp page here
html input passing to jsp method
html input passing to jsp method  i want code in which jsp method takes html input value which is in same page...... <html> <head>...;input type="text" name=pid onblur="m1()" /> <input type="text" name
Output Previous or Next Day of the Month
Output Previous or Next Day of the Month   Please Help! I need... the if...then...else construct and (2) to start using some of the Java API's, by using the String... or previous day: The program should output the next day's or previous day's date
Dialog Box: Input Range Method
Java NotesDialog Box: Input Range Method  This utility method... handle null (CANCEL) or bad input. private static int getInt(String prompt...) { JOptionPane.showMessageDialog(null, "ERROR: Input
input box
input box  give me the code of input box in core java
input box
input box  give me the code of input box in core java
What is the equivalent method in Java which is equivalent to clrscr() in c/c++ . The code should help to clear the output screen ?
What is the equivalent method in Java which is equivalent to clrscr() in c/c++ . The code should help to clear the output screen ?  Hello to all, I have searched the net to know that is there any equivalent method for clrscr
Console Input: Scanner
Java NotesConsole Input: Scanner The java.util.Scanner class (added in Java 5) allows simple console and file input. Of course, your program should... and read input. System.out.println("What's your name, Earthling
plz explain me the output of program - Java Beginners
plz explain me the output of program  Hi friends, can u please explain me the output of below program with proper explanation of each and every line...;Hi Friend, Output of this program is: a=2 b=0 c=0 mul=27 volume=18
How to get the unicode of japanese character input in java
How to get the unicode of japanese character input in java  Good Evening sir/madam; I am trying to create an application in java which needs to show... a function,method or something through which i can get the unicode of japanese
output error
]; for (k=0;k } } if i enter "my name" as the input the output...output error  this is my program import java.io.*; public class separate { public static void main(String[] args)throws IOException
what will the output
what will the output  class Parent has a public method play... the method play() that prints "Child is playing". An instance of Child class... = (Parent) sonu; p.play(); What will be the output of above section of code
Input - Output String Functions
Input - Output String Functions      ... a string data and input them directly into your database. Some special characters...); ?> Output: Actual string is:rose'india After adding slash it become:rose
struts2.2.1 tabular Input example
struts2.2.1 tabular Input example In this example, We will discuss about the Tabular Input validation using struts2.2.1. In this example,We validate the input fields, The Tabular Inputs are used to take the multiple inputs from a form
Skip method in java.
Skip method in java. In this tutorial, we will discuss the use of available... method Returns the integer number of bytes available in this file input stream...;} } Following is the output if you run the application : C:\>java SkipDemo Size
Dialog Box Output
Prev: Do Nothing | Next: Dialog Box Input-Output Java NotesDialog Box Output... dialog boxes. A method is a group of Java statements for doing one...". There is also a similar print method which writes output to the console
While loop break causing unwanted output
. My problem is that when I run this I get to input a int and if correct it will output that I was correct but after that it will output something that I'm... as I'm just beginning learning java. import java.util.Scanner; public class
Method Overloading in java
Method Overloading in java      ... parameters to get the desired output. -- Method Overloading, allows the user to achieve... input parameters. -- The arguments passed to a overloaded method may differ
Change the user input to integer
method show() is taking two variables as input and second method calculate...;} } Output of the program is given below: C:\java>java... Change the user input to integer   
JLabel for output
Java: JLabel for output Why using JLabel for output is usually bad... idea after the user interface is already displayed. For output JTextField is often a better choice. The use of JLabel for output is mentioned because some

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.