Java-Explanation of First Program

Program   Class Declaration The first line class Javaapp declares a class, which is an object-oriented construct. Java is a true object-oriented language and therefore, everything must be placed inside a class. class is a keyword and declares that a new class definition follows. Javaapp is a Java identifier that specifies the name of the … Read more…

Java-Trimming

Trimming To remove whitespace from the beginning and end of a string (but not the interior) you can use the trim( ) method. Program Program Source public class Javaapp { public static void main(String[] args){ String str1 = new String(” haj sof “); System.out.println(str1); System.out.println(“str1.length = “+str1.length()); str1 = str1.trim(); System.out.println(str1); System.out.println(“str1.length = “+str1.length()); } … Read more…