• Register
1 vote
28 views

Problem:

Folks, I hope you are doing well. I started learning java programming very recently. I am on the chapter of Data Type right now of the book from where I am taking the help. There is a problem give in my book’s exercise that: “if you want to manually convert 65 to the letter a, what keyword is needed”?

I can’t really get the problem actually. Is it really possible to do so? If so, then how? Could you please give a hint regarding the problem given above?

Best regards.

12 7 7
15,250 points

Please log in or register to answer this question.

1 Answer

0 votes
 
Best answer

Solution:

Hello Gavin,

As I can understand you wanted to write a program where you can convert a number (65) into a letter (A) but you gave the title of your problem is, “Convert int to the string”

No worries. I am  trying to make it easy for both cases as following below:

public class IntToString 
{ 
  public static void main(String args[]) 
  { 
    int a = 65; 
    String s = Integer.toString(a); 
    System.out.println("String s = " + s);  
  } 
}

On the above code, I used the function Integer.toString() it helps to cast an integer number into a string type.

public class IntToChar
{
  public static void main(String args[])
  {
    int a1 = 65;          
    char ch = (char) a1;
    System.out.println("Integer value: " + a1);
    System.out.println("Char value: " + ch);
  }
}

I really hope it might help you.

13 9 6
94,240 points

Related questions

0 votes
1 answer 17 views
0 votes
1 answer 3 views
3 views
Problem: java how to convert string to char.
asked Mar 26 Dan phillip 4.8k points
1 vote
1 answer 84 views
84 views
Problem: Are the all data type has default values in Java? I am just wondering what is the default value of an integer if I write: int a; boolean b; System.out.println(a); System.out.println(b); All data fields in an object have default values or not? If they have default values what are they? Thanks
asked Mar 26, 2020 Gavin 15.3k points
0 votes
1 answer 2 views
2 views
Problem: I am stuck with this line for a long time.Someone please help me.how to delete a char from a string java
asked 5 days ago ashik 12.9k points
0 votes
1 answer 2 views
2 views
Problem: I need help for solving problem in java:delete a char from a string java
asked 5 days ago ashik 12.9k points
0 votes
1 answer 5 views
5 views
Problem: I need someone’s help to fix it... java for each char in string
asked Mar 25 Ifra 24.4k points
0 votes
1 answer 2 views
2 views
Problem: This started happening all of a sudden. I am just getting the critical error message. Does anyone know how to fix it?
asked Apr 1 zayed1 35.6k points
0 votes
1 answer 5 views
5 views
Problem: Why I got this error: how to convert char array to string in c#? any idea on what I need to fix this. I am new in programming. Thanks in advance.
asked Mar 16 jasimchaudary 1.5k points
0 votes
1 answer 20 views
20 views
Problem: discuss about how to convert string to char array in c++
asked Feb 15 jasimchaudary 1.5k points