Share on Google+Share on Google+

Use char variable as integer

Advertisement
This tutorial demonstrate how to use the char variable as an integer.

Description:

Here in this example you will see how a char variable works like a integer. The char variable works with pre and post increment operators.

Code:

public class CharInt {
  public static void main(String args[]) {
    char charVar;
    for (charVar = 'A'; charVar <= 90; charVar++) {
      System.out.print(charVar);
    }
  }
}

Output:

Download this code

Advertisements

Advertisement

Posted on: June 26, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.