operator • If two operands of + are numbers, it performs an arithmetic addition. • If at least one of operands of + is a string, it performs a string concatenation. • Examples: o 2 + 3 will be 5 o 2 + “ apples” will be “2 apples” o “number ” + 5 will be “number 5” o “we have “ + 2 + 3 will be “we have 23” o “we have “ + (2 + 3) will be “we have 5”
public class MyProgram { } public static void first() { } public static void second() { } public static void main(String[]args) { first(); System.out.println(“”); } System.out println() Java API Math pow() sqrt()
class • The Math class contains various mathematical methods. • To compute √10 double x = Math.sqrt(10.0); • To compute 25.6 double ans2 = Math.pow(2.0, 5.6);
public class MyProgram { } public static void first() { } public static void second() { } public static void main(String[]args) { first(); System.out.println(“”); } System.out println() Java API Math pow() sqrt() public static double PI = 3.141592… ;