Skip to content

String for Java #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Java/String/Caseconvert.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import java.util.Scanner;

public class Caseconvet {





public static void main(String[] args) {
Scanner sc =new Scanner(System.in);

String Str =sc.nextLine();
System.out.println(Str.toUpperCase());
}
}
14 changes: 14 additions & 0 deletions Java/String/LargeSTR.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
public class LargeSTR {


public static void main(String[] args) {
String Fruits[] = {"Nishit","Bhumika","Kapila"};
String Largest = Fruits[0];
for(int i=1 ;i< Fruits.length;i++){
if(Largest.compareTo(Fruits[i]) < 0 ){
Largest = Fruits[i];
}
}
System.out.println(Largest);
}
}
23 changes: 23 additions & 0 deletions Java/String/Str.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import java.util.Scanner;

public class Str {

public static boolean palidrom(String name ){
for(int i=0 ; i<name.length()/2;i++){
int n = name.length();
if(name.charAt(i) != name.charAt(n-i-1) ){
return false;
}

}
return true;
}

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String name ;
name = sc.nextLine();
System.out.println(" The Length Of String is -->"+ name.length());
System.out.println(palidrom(name));
}
}
20 changes: 20 additions & 0 deletions Java/String/Strbuilder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
public class Strbuilder {


public static void main(String[] args) {
StringBuilder sc = new StringBuilder("");
for(char ch='a'; ch < 'z';ch++ ){
sc.append(ch);
}

System.out.print(sc+ " ") ;
}
}

// 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.

/* Important Constructors of StringBuilder class
Constructor Description
StringBuilder() It creates an empty String Builder with the initial capacity of 16.
StringBuilder(String str) It creates a String Builder with the specified string.
StringBuilder(int length) It creates an empty String Builder with the specified capacity as length.*/
27 changes: 27 additions & 0 deletions Java/String/compress.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
public class compress {

public static String compressq(String str){
String newstr = "";
for(int i=0 ; i<str.length() ; i++){
Integer count =1;
while( i < str.length()-1 && str.charAt(1) == str.charAt(i+1) ){
count++;
i++;
}
newstr += str.charAt(i);
if(count > 1){
newstr += count.toString();
}
}
return newstr;
}



public static void main(String[] args) {
String str = "aavv";
System.out.print(compressq(str));

}
}
//time Complexcity O(N) :) #NIshit
8 changes: 8 additions & 0 deletions Java/String/substring.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
public class substring {


public static void main(String[] args) {
String Str = "HelloWorld";
System.out.println(Str.substring(0,5) ); //Java Has a inbulid Funcation of Substring //
}
}