Ascii to string in java

Java convert ascii to string java example

package com.w3spoint;
 
public class ASCIIToString {
  public static void main(String args[]){
	try {
             int num[] = {66, 118, 98, 75};
             String str =null;
             for(int i: num){
               str = Character.toString((char)i);
               System.out.println(str);
             }
	} catch (Exception e) {
		e.printStackTrace();
	}
  }
}

Output:

B
v
b
K

Download this example.

Content Protection by DMCA.com
Please Share