Jump to content

[SOLVED] Java equivalent of Convert.toChar(int) (cSharp) or char(int) (PHP)


Recommended Posts

Hey,

Im in need of a equivalent to PHP's char(int) or C#'s (cSharp) Convert.toChar(int) method in java, simply it needs to be able to work in the same way.

 

I am aware i can do

byte[] char1 = { 1 };

and cast/convert it to a String but this is inconvenient as my program has to use multiple chars frequently. Any help is welcome'd.

-Grey

Found my answer,

package com.hailstorm.message;

public class Char {

public static int decodeChar (char c)
{
	return ((int) c);
}

public static char encodeChar (int i)
{
	return ((char) i);
}
}

 

Can some one please close the thread :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.