Skip to content

Commit dd23a94

Browse files
authored
Create stringStuff.java
1 parent b20d73c commit dd23a94

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

apShenanigans/stringStuff.java

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
2+
public class StringStuff {
3+
4+
public static void main(String[] args) {
5+
6+
String[] testTwo = {"last", "day", "of", "the", "school", "year"};
7+
8+
System.out.println(strArrMethod(testTwo));
9+
10+
11+
for (int j = 0; j < 6; j++) {
12+
System.out.println( j);
13+
}
14+
15+
String e = "str";
16+
17+
System.out.println(e.indexOf("s"));
18+
19+
System.out.println(calcMethod(16));
20+
}
21+
22+
public static int strArrMethod(String[] arr)
23+
24+
{
25+
int count = 0;
26+
27+
String[] result = new String[arr.length];
28+
29+
for (int j = 0; j < arr.length; j++)
30+
31+
{
32+
33+
String sm = arr[j];
34+
35+
for (int k = j + 1; k < arr.length; k++)
36+
37+
{
38+
39+
if (arr[k].length() < sm.length())
40+
41+
{
42+
43+
sm = arr[k]; // Line 12
44+
count++;
45+
46+
}
47+
48+
}
49+
50+
result[j] = sm;
51+
52+
}
53+
return count;
54+
}
55+
56+
public String doubleChar(String str) {
57+
String str1 = "";
58+
59+
for (int i = 0; i < str.length(); i++) {
60+
str1+= str.charAt(i);
61+
str1+= str.charAt(i);
62+
}
63+
return str1;
64+
}
65+
public static int calcMethod(int num)
66+
67+
{
68+
69+
if (num == 0)
70+
71+
{
72+
73+
return 10;
74+
75+
}
76+
77+
System.out.println(num);
78+
return num + calcMethod(num / 2);
79+
80+
}
81+
82+
83+
84+
}

0 commit comments

Comments
 (0)