-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.java
More file actions
194 lines (131 loc) · 4.07 KB
/
Copy pathexample.java
File metadata and controls
194 lines (131 loc) · 4.07 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
// import java.util.Scanner;
// public class example {
// public static void main(String[] args) {
// Scanner sc = new Scanner(System.in);
// System.out.println("Enter n to get Fibbonacci: ");
// int n = sc.nextInt();
// int a = 0;
// int b = 1;
// int count = 2;
// while(count<=n){
// int temp = b;
// b = b+a;
// a = temp;
// count++;
// }
// System.out.println( b);
// }
// }
//---------------------------------------------------------------------
// float f = (2/5)*1;
// float a = Math.round(f); // -- output = 0.0
// // int a = Math.round(f); --output = 0
// System.out.println(a);
//---------------------------------------------------------------------
/*You are passing a reference to an array as the argument to the method.
The method may not modify the passed object reference but it can modify
the object itself.
below */
// int[] a = {1};
// example t = new example();
// t.increment(a);
// System.out.println(a[a.length-1]);
// }
// void increment(int[] j){
// j[j.length-1]++;
// }
//---------------------------------------------------------------------
// }
// to check the count of a perticular digit in a no.
// public class example{
// public static void main(String[] args) {
// int n = 855545;
// int count=0;
// int rem = 0;
// while(n>0){
// rem = n%10;
// if(rem ==5 ){
// count++;
// }
// n =n/10;
// }
// System.out.println(count);
// }
// }
//---------------------------------------------------------------------
// to print the reverse of the given no.
// public class example{
// public static void main(String[] args) {
// int num = 5432;
// int ans = 0;
// int rem = 0;
// while(num>0){
// rem = num%10; //5 //4
// ans = ans*10 + rem; //5 // 50+4
// num = num/10;
// }
// System.out.println(ans);
// }
// }
//---------------------------------------------------------------------
// Basic Calculator
// import java.util.Scanner;
// public class example{
// public static void main(String[] args) {
// int ans = 0;
// Scanner sc = new Scanner(System.in);
// //Take input from user utill user does not press X or x
// while(true){
// char op =sc.next().trim().charAt(0);
// if(op == '+' || op == '-' || op == '*' || op == '/' || op =='%'){
// //input two numbers
// int num1 = sc.nextInt();
// int num2 = sc.nextInt();
// }
// }
// }
// }
//---------------------------------------------------------------------
// functions/methods
//Palindrome no.
// import java.util.Scanner;
// class Solution{
// // public int isPalindrome(int a){
// // while()
// // }
// public static void main(String[] args) {
// Scanner in = new Scanner(System.in);
// System.out.println("Enter a no. to check Palindrome: ");
// int num = in.nextInt();
// int og = num;
// int rev = 0;
// int rem = 0;
// while(num>0){
// rem = num%10;
// rev = rev*10 + rem;
// num = num/10;
// // System.out.println(num);
// }
// System.out.println(rev);
// if (rev == og)
// {
// System.out.println( "is palindrome");
// }else{
// System.out.println("is not palindrome");
// }
// }
// }
public class example {
public static void main(String[] args) {
// System.out.println(Integer.MAX_VALUE);
// System.out.println(Integer.MIN_VALUE);
// String str = "hello";
// str.concat(" world");
// System.out.println(str);
// char ch = 'A';
// ch++;
// System.out.println(ch);
int[] arr = new int[5];
System.out.println(arr[0]);
}
}