StringBuffer Trim Java Example

This example shows how to trim StringBuffer object in Java using substring method. public class JavaStringBufferTrimExample { public static void main(String[] args) { //create StringBuffer object StringBuffer sbf = new StringBuffer(” Hello World ! “); /* * Method 1: convert StringBuffer to string and use trim method of * String. */ String str = sbf.toString().trim(); … Read more

Java Program to Display a Clock Using Applet

This is a Java Program to Display a Clock Using Applet Problem Description We have to write a program in Java such that it creates an analog clock which displays the current system time. Expected Input and Output For displaying a clock, we can have the following set of input and output. To View the … Read more

Java for loop

Java for loop and enhanced for loop is a type of control flow statement which provides a compact way to iterate over a range of values. for loop repeatedly loops through the code until a particular condition is satisfied.  Over the period, Java has added different types of for loop. for loop Enhanced for loop … Read more