Skip to content

Commit 33e27cc

Browse files
Merge pull request #50 from Nishitbaria/main
String for Java
2 parents cb09bb0 + 07bbc7b commit 33e27cc

File tree

6 files changed

+107
-0
lines changed

6 files changed

+107
-0
lines changed

Java/String/Caseconvert.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import java.util.Scanner;
2+
3+
public class Caseconvet {
4+
5+
6+
7+
8+
9+
public static void main(String[] args) {
10+
Scanner sc =new Scanner(System.in);
11+
12+
String Str =sc.nextLine();
13+
System.out.println(Str.toUpperCase());
14+
}
15+
}

Java/String/LargeSTR.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
public class LargeSTR {
2+
3+
4+
public static void main(String[] args) {
5+
String Fruits[] = {"Nishit","Bhumika","Kapila"};
6+
String Largest = Fruits[0];
7+
for(int i=1 ;i< Fruits.length;i++){
8+
if(Largest.compareTo(Fruits[i]) < 0 ){
9+
Largest = Fruits[i];
10+
}
11+
}
12+
System.out.println(Largest);
13+
}
14+
}

Java/String/Str.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import java.util.Scanner;
2+
3+
public class Str {
4+
5+
public static boolean palidrom(String name ){
6+
for(int i=0 ; i<name.length()/2;i++){
7+
int n = name.length();
8+
if(name.charAt(i) != name.charAt(n-i-1) ){
9+
return false;
10+
}
11+
12+
}
13+
return true;
14+
}
15+
16+
public static void main(String[] args) {
17+
Scanner sc = new Scanner(System.in);
18+
String name ;
19+
name = sc.nextLine();
20+
System.out.println(" The Length Of String is -->"+ name.length());
21+
System.out.println(palidrom(name));
22+
}
23+
}

Java/String/Strbuilder.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
public class Strbuilder {
2+
3+
4+
public static void main(String[] args) {
5+
StringBuilder sc = new StringBuilder("");
6+
for(char ch='a'; ch < 'z';ch++ ){
7+
sc.append(ch);
8+
}
9+
10+
System.out.print(sc+ " ") ;
11+
}
12+
}
13+
14+
// Java StringBuilder class is used to create mutable (modifiable) String. The Java StringBuilder class is same as StringBuffer class except that it is non-synchronized. It is available since JDK 1.5.
15+
16+
/* Important Constructors of StringBuilder class
17+
Constructor Description
18+
StringBuilder() It creates an empty String Builder with the initial capacity of 16.
19+
StringBuilder(String str) It creates a String Builder with the specified string.
20+
StringBuilder(int length) It creates an empty String Builder with the specified capacity as length.*/

Java/String/compress.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
public class compress {
2+
3+
public static String compressq(String str){
4+
String newstr = "";
5+
for(int i=0 ; i<str.length() ; i++){
6+
Integer count =1;
7+
while( i < str.length()-1 && str.charAt(1) == str.charAt(i+1) ){
8+
count++;
9+
i++;
10+
}
11+
newstr += str.charAt(i);
12+
if(count > 1){
13+
newstr += count.toString();
14+
}
15+
}
16+
return newstr;
17+
}
18+
19+
20+
21+
public static void main(String[] args) {
22+
String str = "aavv";
23+
System.out.print(compressq(str));
24+
25+
}
26+
}
27+
//time Complexcity O(N) :) #NIshit

Java/String/substring.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
public class substring {
2+
3+
4+
public static void main(String[] args) {
5+
String Str = "HelloWorld";
6+
System.out.println(Str.substring(0,5) ); //Java Has a inbulid Funcation of Substring //
7+
}
8+
}

0 commit comments

Comments
 (0)