jQuery in Action, 2nd edition*
The moose likes Beginning Java and the fly likes a b c Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "a b c" Watch "a b c" New topic
Author

a b c

sunil chandwani
Greenhorn

Joined: Dec 20, 2000
Posts: 19
public class counting{
public static void main(String args[]){
for(int i=0;i<10;i++){
System.out.print(" "+i);
}
}
}
/*Result:
0 1 2 3 4 5 6 7 8 9

The way code given above prints 0 to 9 integers. Can we write a code to
print all small alphabets in this fashion
a b c d e f g h i j k l m n o p q ......z*/
Matthew Jones
Ranch Hand

Joined: Dec 21, 2000
Posts: 68
Yes, and you can do it with just a slight modification of your code.
Try this:

[This message has been edited by Matthew Jones (edited January 16, 2001).]
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
This works because Java thinks in Unicode. The unicode for a=\u0061, b=\u0062 etc.
For a chart of these characters see http://www.unicode.org/charts/PDF/U0000.pdf


"JavaRanch, where the deer and the Certified play" - David O'Meara
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: a b c
 
Similar Threads
Question from jqplus
doubt in multiple assignment !
A SCJP exam question (about array variable assign)
Why doesn't this match?
How to mask string not conforming to a regular expression pattern