Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  
 

Input / Output in Easiest Method in Java

Ads

 
 

Share on Google+Share on Google+

Basumitra Mitra
Input / Output in Easiest Method in Java
1 Answer(s)      6 years and 8 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?

Ads
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


Ads









Related Tutorials/Questions & Answers:
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 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
Advertisements
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
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
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
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 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
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
Easiest method for expiring the css and js headers
Easiest method for expiring the css and js headers  Hi, I have a website with many thousand users visiting per day. I have changes the css file... what could be the easiest method to solve the browser cache issue
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
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
Easiest way to learn Java
There are various ways to learn Java language but the easiest way to learn Java is online. RoseIndia provides Java courses online that helps beginners... of Java. It provides all the material through tutorials, programs, examples
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
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
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
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
java input problem - Java Beginners
java input problem  I am facing a Java input problem
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
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
input - Java Beginners
me soon.  Hi Friend, There are lot of ways to input data.You can use... to input the data from the command prompt. Try the following code to input name...:"); Scanner input=new Scanner(System.in); String name=input.nextLine
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
input
input  a java program that will exchange the last names of two students that were input by a user
java method
java method  can we declare a method in java like this static { System.loadLibrary("nativelib"); } i have seen this in a java learning E book. i don't understand the static { } plz help me. what kind of method
File Handling Classes in Java
In this section, you will get to know about file handling classes in java to handle the file input output operations
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
user input in java - Java Beginners
user input in java   i am trying to write a code to compute the average of 5 numbers but i dont know what to do for the program to accept user input  Hi import java.util.*; public class AverageExample { public
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