Posts

Showing posts from January, 2021

ID and Password Verification (String)

package String; import java.util.Scanner; public class EmailPassVer { public static void main(String[] args) { Scanner sc= new Scanner(System.in); System.out.println("Enter your mail"); String email=sc.next(); Boolean tf=isValid(email); if(tf.equals(false)) { System.out.println("not valid email"); }else { System.out.println("Enter your password"); String pass=sc.next(); String eemail="bikas.shah1921@gmail.com"; String ppass="bikas123"; if(email.equals(eemail) && pass.equals(ppass)) { System.out.println("Login Sucessfully"); }else if (email.equals(eemail)||pass.equals(ppass)) { System.out.println("Email password not match"); }else if(email.isBlank()) { System.out.println("email cannot be blank"); }else if(email.isEmpty()) { System.out.println("email cannot be empty"); }else if(pass.isBlank()) { System.out.printl

A simple method using string to check whether the input password is correct or not

package String; import java.util.Scanner; public class EquilityTest { public static void main(String[] args) { Scanner sc= new Scanner(System.in); System.out.println("Enter the password"); String pass=sc.nextLine(); String password="bikas"; if(pass.equals(password)) { System.out.println("Right password"); }else if(pass.equalsIgnoreCase(password)) { System.out.println("right Password"); }else if(pass.isEmpty()) { System.out.println("Cannot be empty"); }else if(pass.isBlank()) { System.out.println("Dont leave it blank"); } sc.close(); } }

JAVA(String Buffer and String Builder

 package String; public class StringTest { public static void main(String[] args) { /* * Example of immutable string * Immutable means unchangeable7 * Example of string buffer   */ String s="I teach in "; s.concat("Arniko school"); System.out.println(s); //to solve this problem we have string builder StringBuilder sb= new StringBuilder("I teach in "); sb.append("Arniko school "); System.out.println(sb); } }