-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathConcepts.java
More file actions
55 lines (35 loc) · 1.36 KB
/
Concepts.java
File metadata and controls
55 lines (35 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package random;
public class Concep {
public static void main(String[] args) {
String s1= new String("hello world");
System.out.println(s1.charAt(3));
s1.length();//Returns the length of this string
System.out.println(s1.contains("o"));
System.out.println(s1.contains("f"));
char[] chr = {'a','b','c'};
char[] car = {'h','e','d','a',' ','s',' '};
String cop = String.copyValueOf(car);
System.out.println(cop);
String check = String.copyValueOf(car, 2, 4);
System.out.println(check);
String name="MyName";
int number=50;
String formattedString = String.format("Hello my name is %s and i am %d years old", name, number);
System.out.println("Example 1 : "+formattedString);
double pi = 3.14159265;
formattedString = String.format("The value of pi is approximately %.2f", pi);
System.out.println("Example 2 : "+formattedString);
int a = 10;
System.out.println(a);
a = 11;
System.out.println(a);
int age = 3;
formattedString = String.format("her age is %010d", age);
System.out.println("example 3: "+formattedString);
String text ="Hello World";
boolean isStrtWit=text.startsWith("H");//true
boolean isStrtWit2=text.startsWith("o");//false
boolean isStrtWit3=text.startsWith("h");//false
System.out.println(isStrtWit+" "+isStrtWit2+" "+isStrtWit3);
}
}