Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

convert from number (0-255) to character

  Asked By: Craig    Date: Apr 12    Category: Java    Views: 2240
  

I would like to ask for some help, I want to convert
from number (0-255) to character, and what I do is:

for (int i =0;i<255;i++) {System.out.println
((char)i);}

Some number appears as "?" and some number is appears
not correctly.

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Betty White     Answered On: Apr 12

what you want to do is just to change/convert integers to character  and i
run that line too it is just printing character who's ascii is that like in
0-255 there may be sapce, or some special character so check it with an ascii
chart.

 
Answer #2    Answered By: Muhammad Abdullah     Answered On: May 02


//I had Answer for You But it is in C++.May be this help you and you wil change it //into Java
#include<iostream>
using namespace std;

int main()
{
	char complete_character[255],a ='!';
	for(int i=0;i<255;i++)
	{
		complete_character[i] = a+i;
	}
	for(int i=0;i<255;i++)
	{
		cout<<complete_character[i]<<endl;
	}
	system("pause");
}

 
Didn't find what you were looking for? Find more on convert from number (0-255) to character Or get search suggestion and latest updates.




Tagged: