- Write a program to print a semicolon without using a semicolon anywhere in the code in java.
- Write a program to print"hello world"without using semicolon anywhere in the code.\
- Yes we can print ";" without using semicolon in java by using printf in java.
- Format text using printf in java here we have provided information about how to format text using printf in java.
- In the same way we can print ";" using printf .
- ASCII value for ";" is 59. So if we print 59 in character format it will print ;
- System.out.printf("%C",59).
- But in java program end of every statement we need to keep ";". To eliminate this we can use if condition.
- Keep print statement inside if condition and it will print the ";" now.
- Now let us see an example java program to print a semicolon without using a semicolon anywhere in the code in java.
Program #1: Write a program to print a semicolon without using a semicolon anywhere in the code in java
- package instanceofjava;
- /**
- * Print semicolon without using semicolon in java
- * Print hello world without using semicolon java program code
- * @author www.instanceofjava.com
- */
- public class PrintSemiColon {
- public static void main(String[] args) {
- if(System.out.printf("%C",59) != null){
- }
- }
- }
Output:
- ;
Program #1: Write a program to print hello world without using a semicolon anywhere in the code in java
- package instanceofjava;
- /**
- * Print semicolon without using semicolon in java
- * Print hello world without using semicolon java program code
- * @author www.instanceofjava.com
- */
- public class PrintSemiColon {
- public static void main(String[] args) {
- if(System.out.printf("Hello World")!=null){
- }
- }
- }
Output:
- Hello World
No comments