Methods Example Output: String Class

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

JOEY BRANDELL CRUZ PROGIT2

BSIT – IDB3

STRING CLASS

Methods Example Output


trim() String s=" Burger "; (space)Burger(space)
System.out.println(s); Burger
System.out.println(s.trim());
startsWith() String s="Sausage"; true
endsWith() System.out.println(s.startsWith("Sa")); true
System.out.println(s.endsWith("e"));
charAt() String s="Cheese"; C
System.out.println(s.charAt(0)); s
System.out.println(s.charAt(4));
length() String s="Ketchup"; 7
System.out.println(s.length());
intern() String s=new String("Balut"); Balut
String s2=s.intern();
System.out.println(s2);
valueOf() int a=19; 1910
String s=String.valueOf(a);
System.out.println(s+10);
replace() String s1="I like me better, just me I like you better, just
and me."; you and you
String
replaceString=s1.replace("me","you");
System.out.println(replaceString);

MATH CLASS

Method Example Output


Math.max() int x = 60; int y = 192; 192
System.out.println(Math.max(x, y));
System.out.println(Math.max(x, y));
Math.min() 60
Math.abs() int x = 80, int y = -48; 80
System.out.println(Math.abs(x)); 48
System.out.println(Math.abs(y));
Math.round() double x = 30.59; 31
System.out.println(Math.round(x));
Math.sqrt() double x = 81.0, y = 729; 9.0
JOEY BRANDELL CRUZ PROGIT2
BSIT – IDB3

Math.cbrt() System.out.println(Math.sqrt(x)); 9.0


System.out.println(Math.cbrt(x));
Math.getExponent() double a = 50.45; 5
System.out.println(Math.getExponent(
a));
Math.IEEEremainder() double a = 387.1, b = 4.2; 0.7000000000000
System.out.println(Math.IEEEremainde 064
r(a, b));
Math.addExact() int a = 100; int b = 50; 150
Math.subtractExact() System.out.println(Math.addExact(a, 100
Math.multiplyExact() b)); 5000
System.out.println
(Math.subtractExact(a, b));
Math.incrementExact() int a = 310; 311
Math.decrementExact( System.out.println(Math.incrementExa 309
) ct(a));
System.out.println(Math.decrementEx
act(a));
Math.nextUp() double x = 744.93; 744.93000000000
java.lang.Math.nextDo System.out.println(Math.nextUp(x)); 01
wn() float a = 328.7f; 328.69998
System.out.println(Math.nextDown(a));
Math.ceil() double x = 83.56; 84.0
Math.floor() System.out.println(Math.ceil(x)); 83.0
System.out.println(Math.floor(x));
Math.log() double x = 38.9; 3.6609942506244
System.out.println(Math.log(x)); 004
Math.sin() double a = 60; 0.8660254037844
double b = Math.toRadians(a); 386
System.out.println(Math.sin(b));
Math.cos() double a = 60; 0.5000000000000
double b = Math.toRadians(a); 001
System.out.println(Math.cos(b));
Math.tan() double a = 45; 0.9999999999999
double b = Math.toRadians(a); 999
System.out.println(Math.tan(b));
Math.asin() double a = 1.0; 1.5707963267948
System.out.println(Math.asin(a)); 966

You might also like