-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJava_Test.java
More file actions
133 lines (103 loc) · 2.29 KB
/
Java_Test.java
File metadata and controls
133 lines (103 loc) · 2.29 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
package com.newTest;
public class Java_Test {
public static void testString1()
{
String text="abc";
System.out.println(text.hashCode());
}
public static void testSwitch(char ch)
{
switch(ch)
{
case 'a': System.out.println("a");
break;
case 'b':System.out.println("b");
break;
case 'c': System.out.println("c");
default:
System.out.println("none");
}
}
public static void reverseString(String input)
{
String splitArr[] = input.split(" ");
String revString ="" ;
for(String str:splitArr)
{
String revChar = "";
int len = str.length();
for(int i=len-1 ; i>=0 ; i--)
{
revChar =revChar+str.charAt(i);
}
revString = revString + revChar +" " ;
}
System.out.println("print reverse string:- "+revString);
}
public static void testArray1()
{
int arr[]= new int[2];
arr[0] = 2;
arr[1] = 3;
}
//show method that has array as a return type
public static int[] testArray2()
{
int newarr[]= {1,2,3,4};
return newarr ;
}
//show method that accepts array as a parameter
public static void testArray3(int arr[])
{
int charr []=arr;
for(int i=0 ; i<charr.length ;i++)
{
System.out.println(charr[i]);
}
System.out.println("print the first character: "+charr[0]);
System.out.println("print the last character: "+charr[charr.length-1]);
}
public static void test(int n)
{
for(int i=0 ; i<n ; i++)
{
for(int j=n-1 ; j>=i ; j--)
{
System.out.print("*");
}
System.out.println();
}
}
public static void fib()
{
int i = 2;
String val = Integer.toString(i);
System.out.println(String.valueOf(val));
boolean bool = val instanceof String;
System.out.println(bool);
}
public static void fibonacci(int len)
{
int f1 = 0;
int f2 = 1;
int f3 = 0 ;
System.out.print(f1+" "+f2);
for(int i=0 ; i<len ; i++)
{
f3 = f1+f2 ;
System.out.print(" "+f3+" ");
//int temp =
f1=f2;
f2=f3;
}
}
public static void main(String[] args)
{
//testSwitch('b');
//testArray3(testArray2());
//test(5);
//fib();
//fibonacci(8);
reverseString("moumita dey");
}
}