Java Snippets

Hamburger icon

ASCII code

This is a very simple program that will simply print the ASCII code of any text you enter.

There is nothing else to say, really. You are seeing the silliest of the Java snippets in this page.

Here is the code

/* ---------------------------------------------
 *			CLASS ASCII
 * ---------------------------------------------*/

package ascii;

import java.io.*;

class Ascii {

	public static void main (String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		System.out.print("\nIntroduce some text: ");
		String s = br.readLine();

		for (int i = 0; i < s.length(); i++) {
			System.out.println("Character '" + s.charAt(i) + "', ASCII code = " + (int)s.charAt(i) );
		}
	}
}
View ASCII's repo