Category: 6. Input Output Programs

  • Program to get input from user

    In this tutorial we are gonna see how to accept input from user. We are using Scanner class to get the input. In the below example we are getting input String, integer and a float number. For this we are using following methods:1) public String nextLine(): For getting input String2) public int nextInt(): For integer input3)…

  • Program to get IP address

    In this example we are gonna see how to get IP address of a System. The steps are as follows: 1) Get the local host address by calling getLocalHost() method of InetAddress class.2) Get the IP address by calling getHostAddress() method. Output:

  • Program to read integer value from the Standard Input

    Example: Program to read the number entered by user We have imported the package java.util.Scanner to use the Scanner. In order to read the input provided by user, we first create the object of Scanner by passing System.in as parameter. Then we are using nextInt() method of Scanner class to read the integer. If you are new to Java…