answersLogoWhite

0

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 .

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

What is string class features in java?

String class is useful to accept inputs from commands prompt as string arguments


How do you input the number of characters in java?

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


What is the defualt value for String in java?

The default value for objects is null; I believe this would apply to a String, too, since Strings are objects.


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;


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); } }


How do you use the Scanner class to store two words or more in a String variable then the next input in another String variable in java?

Scanner scan = new Scanner("[input method]"); // input method could they key board //(System.in) or a String String one = scan.next() + scan.next(); // get the first 2 words and concatenate String two = scan.next(); // the remaining word


Java program to give input of a string and display it?

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); } }


How do I turn Java on?

Install Java. It is "on" by default.


What are some example for string formatting in Java?

There are lots of examples of string formatting in Java. It can be difficult at times. Some of these examples are, but are not limited to; align, string, format, and JAVA.


How a class in java declared default?

default it is public type


How does java accept input from the keyword?

Java gives us access to standard input from System.in, which is an InputStream object. You can use it like any other InputStream and call the read() method to read a single byte of input, or you can wrap it in a more robust class (BufferedReader, BufferedInputStream) for more options. the user can insert any keyword because JAVA and all the programming languages do not compile anything between quotations "this is the sample input".


What does it mean to have a string split in java?

To have a string split in Java means that a string array, containing substrings (can be delimited by elements of a specified string or Unicode character array), is returned.