answersLogoWhite

0

import java.util.*;

public class Example

{

public static void main(String[] args)

{

Scanner in = new Scanner(System.in);

System.out.println("Please enter a string:");

String input = in.next();

System.out.println("The String you entered is: " + input);

}

}

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

Write a program in java to display a string message using Servlets?

i dont no string for servlate


How to Write a java program to display hello?

public class Hello{public static void main(String [] args){System.out.println("Hello");}}


Accept 2 no and display it in java?

package scanPackage; //Importing Scanner import java.util.Scanner; public class display { public static void main(String[] args) { //Creating scanner Object Scanner scan = new Scanner(System.in); //Taking first system input String str1 = scan.nextLine(); //Taking second system input String str2 = scan.nextLine(); //Printing both Input System.out.println(str1); System.out.println(str2); } }


Why does Java accept any input as string by default?

Java doesn't always accept any input as a string it only do that when the input is entered from the " JOptionPane.InputDialog" but it can accept any other data type like integer or short from the console though Scanner class .


What is javadoc?

write a java program to display "Welcome Java" and list its execution steps.


How does the string trim work in Java?

The string trim works in Java by trimming white space from the beginning and end of a string. It cleans up the string and makes makes it neater for the users of the program.


How do you input the number of characters in java?

".length()". The . length method is inherited from the String class.


What Program that will display the even numbers in data structures and algorithms?

JAVA


How do you get a Java program to display a backslash in output without it interpreting it as a program command?

Follow the backslash with another backslash: System.out.println("\\ " \"); will display \ " \ on the screen.


Why we use IntegerParseInt in java?

Parsing is very important since the input from the user is not in the form of ints but in a String, therefore, you have to parse the String containing the number into a primitive data type. i.e. String num = "49"; int realNum = Integer.parseInt(num); // puts 49 into realNum;


Can you please display me a java program that displays description of animals as output?

public class Animals { public static void main (String args[]) { System.out.println ("cats are nice, dogs are ugly"); } }


Write a java program to count the space from the given line?

.... String line = "This is example program with spaces"; String[] tokens = line.split(" "); System.out.println(tokens.length-1); .......