This is the simple java program for beginners about string. The program compare two strings and generate the results which is greater string.
Source Code
import java.util.Scanner; public class LinkedList { public static voidmain(String args[]) { Stringf_String; String s_String; Scanner in = new Scanner(System.in); System.out.println("Enter First String :"); f_String = in.nextLine(); System.out.println("Enter Second String :"); s_String = in.nextLine(); if ( f_String.compareTo(s_String) > 0 ) { System.out.println("First String Less Than Second ! "); } else if ( f_String.compareTo(s_String) < 0 ) { System.out.println("First String Greater Than Second ! "); } else { System.out.println("Strings Equal !"); } } }
Output of the Program
Compare Strings |
0 comments:
Post a Comment