I want to give user with 2 choices which are whether reading the node in alphabets or numbers. It will say something like "From node A to B" or "From node 1 to 2". So I wrote codes like the //2 code(I want to make it simple so I let the condition to be "true"). But the result is "66" instead of "B". However, the //1 code works fine. How can I wrote the code that allows me to change the letter and display correctly the way I want? Thanks.
System.out.println(true?(char)(65+1):65);//1
int a=65;
System.out.println(true?(char)(65+1):a);//2
Results
B
66
*Try to make it clearer: I want to make a loop to print out
From node A to node B
From node A to node C
From node A to node D
...
So I will write
for (int i=1;i<26;i++)System.out.println("From node A to node "+ (char)(65+i));
But I also want to make it able to print out this if user decide to:
From node 1 to node 2
From node 1 to node 3
From node 1 to node 4
...
So, I make a question about the format the user wants as a boolean format
variable. And I edit the code to be
boolean format=true;//I simplify it
for (int i=1;i<26;i++)System.out.println("From node "+(format?"A":1)+ " to node "+ (format?(char)(65+i):i));
Here is there result
From node A to node 66
From node A to node 67
From node A to node 68
...
This is not what I want. It should be "From node A to node B", etc... I changed the short type in //2 to int as recommended, but it(type) is not the point I'm asking. So please don't mind it.