• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 275
  • Last Modified:

tilda java output

Hi,

I am trying below program

public class test {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
exByte();
	}
	
	public static void exByte(){
		
		char tt='A';
		tt='\u223c';//tilda
		tt=0x223c;//hexa value of tilda
		System.out.println("tt is"+tt);
		System.out.println("tt is"+(int)tt);
	}

}

Open in new window


i got below output
tt is?
tt is8764


i expected tilda but got ? as out put
also why below statement
System.out.println("tt is"+(int)tt);
gave 8764.
where can i see all these list of values in binary integer hex for all the characters, numericals?

please advise
0
gudii9
Asked:
gudii9
3 Solutions
 
ozoCommented:
Your display device may be using an ASCII or ISO-8859 character set.
You might want to try
 tt=0x7e;
0
 
CEHJCommented:
http://technojeeves.com/index.php/aliasjava1/16-javasystemproperties

file.encoding

is the property you should print. Then examine the encodings for that character set by googling
0
 
mccarlIT Business Systems Analyst / Software DeveloperCommented:
also why below statement
System.out.println("tt is"+(int)tt);
gave 8764.
Because 0x223C in HEX equals 8764 in decimal, and Java's representation of an integer (when converting it to a string which you are implicitly doing on line 17) is as a decimal.
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
gudii9Author Commented:
public class test {

      /**
       * @param args
       */
      public static void main(String[] args) {
            // TODO Auto-generated method stub
exByte();
      }
      
      public static void exByte(){
            
            char tt='A';
            tt='\u223c';//tilda
            tt=0x7e;//hexa value of tilda
            System.out.println("tt is"+tt);
            System.out.println("tt is"+(int)tt);
      }

}

above gave output
tt is~
tt is126
0
 
gudii9Author Commented:
Your display device may be using an ASCII or ISO-8859 character set.
You might want to try
 tt=0x7e;

how do i know which one is being used by device( what you mean by device ? windows dell laptop i am using and elipse is ide i am working to run) please advise
0
 
gudii9Author Commented:
public class Props {
    /**
     *  The main program for the Props class
     *
     * @param  args  One or no arguments. If one,
     * the key of one system property, the value
     * of which you want to know. If none, all
     * properties are listed
     *
     */
    public static void main(String[] args) {
        if (args.length > 0) {
            for (int i = 0; i < args.length; i++) {
                System.out.println(System.getProperty(args[0]));
            }
        } else {
            System.getProperties().list(System.out);
        }
    }
}

Open in new window


i ran above program i do not find ascii or is0-8859.
please advise
0
 
CEHJCommented:
i ran above program i do not find ascii or is0-8859.
please advise
So what DID you get?
0
 
gudii9Author Commented:
i see lot of other things when i ran on office laptop. i will try on personal laptop and post.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now