Program to print non English characters in Java

You might wonder, how to print Non English characters using Java.

Below is program, which initializes a String literal, using Hexa decimal notation, which has non english characters.

public class multiplyu {
public static void main(String[]args){
	String str = "u0905u0906u0907u0908u0909u0910u0911";
	System.out.println("Non-English Characters:"+str);

In above program, 0905, 0906, 0907, 0908, 0909, 0910 and 0911 are Hexadecimal representation of Hindi characters. Each of these hexa decimal code need to be prefixed with u to indicate that these are hex literals.

Similarly any Unicode characters can be initialized to String object, and can be printed.

Below is output screen shot:

Print non English characters in Java
Print non English characters in Java

In Eclipse, by default Work space Encoding is Cp1252, which can print only English characters in Console.

Below steps can be used to print non-English characters in Eclipse console.
1.Select Window
2.Select Preferences
3.then Select, WorkSpace
4.On right section, select ‘Text File Encoding’ as UTF-8

Print Non Ascii characters  using Java
Print Non Ascii characters using Java

What are primitive data types in Java?

Primitive data types are built in data types. Primitive data types are also called as Basic data types.

1.Integer Types

Different Types differ in memory size and range of values.

Integer Type Size Range
byte 1 byte -128 to 127
short 2 bytes -215 to (215)-1
int 4 bytes -231 to (231)-1
long 8 bytes -263 to (263)-1

In java, only signed integers exist. Java does not have signed and unsigned keywords.
Unsigned values are not supported in Java

byte binary representation
byte binary representation

2.Decimal Types

There are two decimal types supported in Java. Below table, shows details on the same.

Decimal Type Size Range
float 4 bytes -3.7e-38 to 3.7e+38(Scientific notation)
double 8 bytes -1.4e-308 to 1.4e+308

NOTE:-3.7e-38 means -3.7 X 10 power of -38
Scientific notation is used to express very small or big values

How to declare and initialize float and double?
float abcd=1.2f;
double wxy=4.67;

3.Character Type

In C language 1 byte is used to store each character
ASCII(can represent only 255 different characters), and supports only English related characters
In Java 2 bytes are used to store each character. UNICODE is the code used to store characters in Java.
UNICODE Can represent 65,535 different characters.
Though UNICODE uses extra 1 byte, for each character, it supports most of the international characters directly, unlike ASCII code.
Java has built in support for internationalization(i18n)


boolean data type is used to represent only two values true or false. boolean uses 1 bit of storage

Above are eight primitive data types in Java.

You may also like to read:
String object with and without new?
Difference between equals() and ==?