Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java read string input

import java.util.Scanner;
 
public class YourClass {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String inputString = scanner.nextLine();
        System.out.println("Your string: " + inputString);
    }
}
Comment

java input - how to read a string

import java.util.Scanner;  // Import the Scanner class

class Main {
  public static void main(String[] args) {
    Scanner myObj = new Scanner(System.in);  // Create a Scanner object
    System.out.println("Enter username");

    String userName = myObj.nextLine();  // Read user input
    System.out.println("Username is: " + userName);  // Output user input
  }
}
Comment

PREVIOUS NEXT
Code Example
Java :: get spring application context 
Java :: File Appender log4j2.properties spring 
Java :: smart ways to print a matrix in java 
Java :: java array sorting java8 
Java :: java throws keyword 
Java :: java all characters in alphabet order simpler 
Java :: how to replace an element in array in java 
Java :: linked list java 
Java :: declare generic set java 
Java :: java get size of array 
Java :: arraylist 
Java :: Java The Throw/Throws Keyword 
Java :: can i run script in ubuntu using java 
Java :: java polymorphism 
Java :: java read file from command line argument 
Java :: java create arraylist with size 
Java :: stringbuilder java 
Java :: spring @value default value 
Java :: get role assigned to a user inside spring controller 
Java :: java Convert a string IPv4 IP address to the equivalent long numeric value. 
Java :: android gridview item click effect ripple 
Java :: how to create a java library in intellij 
Java :: stream.concat 
Java :: linked list vs vector 
Java :: JAVA Character Literals 
Java :: what is use of drivermanager class 
Java :: euclidean algorithm java recursive 
Java :: array.swap java 
Java :: java local function 
Java :: python discord embed generator 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =