Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import static java.lang.Integer.max;
- import java.util.ArrayList;
- import java.util.Scanner;
- public class NewClass1 {
- public static void main(String[] args){
- //String Declaration :
- String s1 = "Imran Mohammed";
- String s2 = new String("imran mohammed");
- System.out.println(s1);
- System.out.println(s2);
- //Finding Length :
- int len = s1.length();
- System.out.println(len);//14
- //Check Equality (Object)
- if(s1 == s2){
- System.out.println("String are equal");
- }
- else{
- System.out.println("String are not equal");
- }
- //Check Equality With case
- if(s1.equals(s2) ){
- System.out.println("String are equal");
- }
- if(s1.contains(s2)){
- System.out.println("String are equal");
- }
- //Check Equality Ignoring case :
- if(s1.equalsIgnoreCase(s2)){
- System.out.println("String are equal");
- }
- //Check String Contain or not :
- boolean con = s1.contains("Mohammed");
- System.out.println(con);
- //Check empty or not :
- boolean b = s1.isEmpty();
- System.out.println(b);
- //String Declaration :
- String s1 = "Imran Mohammed ";
- String s2 = new String("Sanvi");
- //String Concatation :
- String s3 = s1.concat(s2);
- System.out.println(s3);
- //Convert Uppercase :
- String uppername = s3.toUpperCase();
- System.out.println(uppername);
- //Convert Lowerrcase :
- String lowername = s3.toLowerCase();
- System.out.println(lowername);
- //Check Start with Something :
- boolean b = s1.startsWith("I");
- System.out.println(b);
- //Check end with Something :
- boolean l = s1.endsWith("d");
- System.out.println(l);
- }
- }
Add Comment
Please, Sign In to add comment