We can code Java in English as well as in many other languages like Marathi, Hindi etc. In order to make Java code readable in another language we have to change our program’s encoding to “UTF-8 Encoding”.
public class AnyLanguageUser {
public static void main(String []yuvraj_patil){
int त्रिज्या = 20;
int व्यास = 2 * त्रिज्या;
System.out.println(व्यास);
}
};
- Using IDE (Eclipse)
- Write this program in Java Project of Eclipse.
- While saving the program, save it’s encoding as “UTF-8 Encoding”.
- Run as usual, it will print 40.
- Write the above program in a java file and name that file as “AnyLanguageUser.java”
- While saving the program save it’s encoding as “UTF-8 Encoding”.
- Open the CMD prompt and compile it as below
- Run it as below using the CMD prompt
javac –encoding UTF-8 AnyLanguageUser.java
java AnyLanguageUser
Similarly we can write method names in local languages in the following way
public class AnyLanguageUser {
public static void main(String []yuvraj_patil){
int लांबी = 20;
int रुंदी = 10;
int क्षेत्रफळ = त्रिकोणाचेक्षेत्रफळमोजणे(लांबी , रुंदी ) ;
System.out.println(क्षेत्रफळ) ;
}
public static int त्रिकोणाचेक्षेत्रफळमोजणे (int लांबी,int रुंदी ){
int क्षेत्रफळ = लांबी * रुंदी ;
return क्षेत्रफळ;
}
};