user7627726 :
I am trying to make a program which prints all Unicode symbols \u6000 through \u7000(1000 symbols). My program prints 50 characters, starts a new line, prints 50 more, etc. (no issue there).
I know how to print Unicode symbols, but I am not sure how to print them incrementally (adding 1 each time). Here is my program:
public class UnicodePrinter {
public static void main(String args[]) {
for (int i = 6000; i<7000; i++) {
if(i%50 == 0) {
System.out.println();
}
System.out.print("\u"+i); //issue here, see below
}
}
}
I get an error on my print statement, where I typed "\u"+i
saying "Invalid unicode" because \u
is not completed with numbers, but I have no idea how to fix it.
Kevin Anderson :
Just generate the char
s directly, like this:
public class UnicodePrinter {
public static void main(String args[])
{
for (char i = '\u6000'; i < '\u7000'; i++) {
if (i % 50 == 0) {
System.out.println();
}
System.out.print(i); //issue here, see below
}
}
}
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=476742&siteId=1