-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotebook.java
More file actions
55 lines (49 loc) · 1.88 KB
/
Copy pathnotebook.java
File metadata and controls
55 lines (49 loc) · 1.88 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
//import java.util.Random;
public class notebook {
public static void main(String[] args){
//testing random
/*Random random = new Random();
int n = random.nextInt(10)+1;
System.out.println(n);*/
//testing printf statements
/*String name = "Subhash";
int age = 18;
double cgpa = 7.13;
boolean isstudent=true;
char currency='$';
System.out.printf("User name : %s\n",name);
System.out.printf("Age : %d\n",age);
System.out.printf("cgpa : %.4f\n",cgpa);
System.out.printf("Student : %b\n",isstudent);
System.out.printf("currency : %c\n",currency);*/
/*double price1=859626.25;
double price2=486668.59;
double price3=-78316.32;
System.out.printf("% .3f\n",price1);
System.out.printf("% .3f\n",price2);
System.out.printf("% .3f\n",price3);*/
/*int id1=1;
int id2=23;
int id3=456;
int id4=7890;
System.out.printf("%04d\n",id1);
System.out.printf("%04d\n",id2);
System.out.printf("%04d\n",id3);
System.out.printf("%04d\n",id4);
System.out.printf("%4d\n",id1);
System.out.printf("%4d\n",id2);
System.out.printf("%4d\n",id3);
System.out.printf("%4d\n",id4);
System.out.printf("%-4d\n",id1);
System.out.printf("%-4d\n",id2);
System.out.printf("%-4d\n",id3);
System.out.printf("%-4d\n",id4);*/
String name = "Vikram singh rathod";
int length = name.length();
System.out.println("length of string : "+length); //counts with spaces
char letter = name.charAt(5);
System.out.println("At index 0 : "+letter); //returns characters at specified index
int index = name.indexOf("g");
System.out.println("Index of G : "+index);//returns index no without counting spaces
}
}