- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java Program to display printable characters
To display printable characters, you need to work with the ASCII values from 32 to 127.
With that, we are using the following, instead of System.out.println()
System.out.write();
The following displays all the printable characters.
for (int i = 32; i < 127; i++) { System.out.write(i);
Let us see the complete example.
Example
public class Demo { public static void main(String []args) { System.out.println("Printable characters..."); for (int i = 32; i < 127; i++) { System.out.write(i); if (i % 8 == 7) System.out.write('
'); else System.out.write('\t'); } System.out.write('
'); } }
Output
Printable characters... !"#$%&' ()*+,-./ 01234567 89:;<=>? @ABCDEFG HIJKLMNO PQRSTUVW XYZ[\]^_ `abcdefg hijklmno pqrstuvw xyz{|}~
- Related Articles
- Java Program to check whether the character is ASCII 7 bit printable
- How to trim down non printable characters from a string in Python?
- How can we display MySQL bit values in printable form?
- Java Program to Swap Pair of Characters
- Java program to display English alphabets
- Java Program to Display Fibonacci Series
- Java Program to display upper triangular matrix
- Java Program to find duplicate characters in a String?
- Java program to check order of characters in string
- Java Program to display JTabbedPane on the right
- Java Program to display the contents in JTextArea
- Java Program to display Frame after some seconds
- Java Program to display sub-list of ArrayList
- Java Program to display a webpage in JEditorPane
- Java Program to display computer time in milliseconds

Advertisements