• Register
1 vote
17 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

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

1 vote
1 answer 81 views
81 views
Problem: I am looking for a solution to my existing code. Well, I am a new student of java. I was thinking about a program that can check whether the given char is an upper case or not! Let’s say I’ve given a char as ‘a’ and I want ... , my question is, how to check whether a char variable ch is an uppercase letter, you write? Thanks for your valuable time and effort guys.
asked Mar 22 Gavin 15.3k points
0 votes
1 answer 5 views
5 views
I want a program that will help me to copy one file to another file in Java.
asked Sep 22 Daniel Anderson 4k points