answersLogoWhite

0


Best Answer

I assume that your scanner is not scanning a string already, so if you are scanning an int then you can do: for the example you scanner variable is x .... x.intparseString();

User Avatar

Wiki User

10y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you convert a scanner to string in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you convert string to int in Java?

One can convert a string variable to an int variable in Java using the parse integer command. The syntax is int foo = Integer.parseInt("1234"). This line will convert the string in the parenthesis into an integer.


How can you convert byte to string in java?

To convert byte to String in java use the String(bytes, UTF-8); //example for one encoding type. You must know the special encoding that contains a variety of characters.


Java program to convert lowercase to uppercase?

You can use the toUpperCase() method on a String to convert any String to all uppercase.


How can someone convert string to int in Java?

To convert string to int in Java, the easiest way is to simply use the method Integer.parseInt(). For more information how to do this, refer to the integer class documents.


What is the code required to convert an integer variable to a string variable in Java?

There are several different methods to convert an integer variable to a string variable in Java. For example, one can use the following code to convert an integer variable to a string variable: Integer.toString(number)


Which is the best way to convert numbers in string under java?

All of the Java number classes have a parse[type] method, like parseInt() in Integer or parseDouble() in Double that convert Strings to primitive numbers. String s = getInput(); int var = Integer.parseInt(s);


How do you convert capital string to small in Java?

To convert a String object to lowercase in Java, use the toLowerCase() method. "HELLO".toLowerCase() returns a new String: "hello".


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 can you make object from string in java?

String itself is an object dude... If you want an object out of a string then you can do this. Object obj = (Object) str; //str is the String you want to convert to object.


How do you convert an integer to a string?

That really depends on the programming language. In Java, it is sufficient to concatenate it with a String: int myNumber = 5; result = "" + myNumber; Other languages may require a special function, or method, to convert from integer to string.


How to write A Java program to print number of digits in a given number?

One way to do this is to convert the number to a String, then use the corresponding String method to find out the length of the String.