Math and Strings
Math and Strings
4)
public class Example {
public static void main(String[] args) {
char i = 30 + 35;
System.out.println("i is " + i);
int j = 2 + 'a';
System.out.println("j is " + j);
System.out.println(j + " is the Unicode for character " + (char)j);
System.out.println("Chapter " + '9');
}
}
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
5)
public class Example {
public static void main(String[] args) {
String s1 = "Welcome to Java";
String s2 = " Programming is fun";
String s3 = "Welcome to Java";
System.out.println(s1 == s2);
System.out.println(s2 == s3);
System.out.println(s1.indexOf('j'));
System.out.println(s1.indexOf("to"));
System.out.println(s1.length());
System.out.println(s1.toLowerCase());
System.out.println(s1.toUpperCase());
System.out.println(s1.concat(s2));
}
}
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………