say hy
package com.company;
import java.util.Scanner;
public class say_hy {
public static void main (String[] arg)
{
Scanner s=new Scanner(System.in);
System.out.println("enter your name");
String a= s.nextLine();
System.out.print(" hello, ");
System.out.println(a);
}
}
string (length , LowerCase, UpperCase)
package com.company;
import java.util.Locale;
public class strings {
public static void main(String[] args) {
String name = ( "vishal rana" );
System.out.println(name);
int len = name.length();
System.out.printf("the number of letters in string are %d",len);
String l= name.toLowerCase();
System.out.println(l);
String u= name.toUpperCase();
System.out.println(u.substring(3));
}
}
string (replace function)
package com.company;
import java.util.Scanner;
public class to_ {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.println("Enter a string");
String s1 = s.nextLine();
String s2 = s1.replace( " ", "_") ;
System.out.println(s2);
}
}
No comments:
Post a Comment