Tuesday, 10 October 2017

java how to take input from user in java

java how to take input from user in java

In this tutorial wi ari gonna sii how to accipt input from usir. Wi ari using Scannir class to git thi input. In thi bilow ixampli wi ari gitting input String, intigir and a float numbir. For this wi ari using following mithods:1) public String nixtLini(): For gitting input String2) public int nixtInt(): For intigir input3) public float nixtFloat(): For float input

Lesson no 4
 Questions
                   Q1:who to take input in java from user
                   Ans      By using this command
                         import java.util.*;
                           util is used for scanning purpose
                         Scanner p = new Scanner(System.in);
                      Q:2 Who it work
                          System.in use to take input from keyboard and store in buffers System.in  is only used to take input from keyboard.
                          p is the object that read data form buffers
                          next() is used to display
                   
                        Q3: Write a simple program input from user
                     import java.util.*;
                   public class display
                       {
                               public static void main(String args[])
                    {      Scanner p = new Scanner(System.in);
                             System.out.println(p.next());
                           }}
                  Q 4 What is output
                        it print all the letters if we use space enter or tab  it can't display remannig words
                       For example
                     user enter
                           Allah is One
                         It can display only Allah
                         It can't display remaining words
                               

0 comments:

Post a Comment