+ 1
Check my code plz.
Hey who can help me check this code as the question is as follows Write a program that prompts the user to enter an integer number and convert the int to String using Integer class This is my attempt: package convertinttostring; import java.util.Scanner; public class ConvertIntToString { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter an Integer value: "); Integer One = input.nextInt(); String Tow = One.toString(); System.out.println("Convet Int to String will be as: " + Tow); } } And the run was as the follows: Enter an Integer value: 11 Convert Int to String will be as: 11 So my attempt is True or False?
3 Respostas
+ 1
ToString is a method of Object i think, so probably not what you are supposed to do. Search Integer class in Java documentation and see if there is another method.
Besides that Tow is obviously a string by definition
+ 1
You can.Integer class has a method of toString() to convert to string..
edit:
you already did
Integer.toString(num);
0
please show me how I can make this in a code?
Jayakrishna🇮🇳