-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringinjava.java
More file actions
32 lines (28 loc) · 919 Bytes
/
Stringinjava.java
File metadata and controls
32 lines (28 loc) · 919 Bytes
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
public class Stringinjava {
public static void main(String[] args) {
//simple String
// String s="sdrgjkjhg";
//how to mak new string
String s1=new String("Utkash Tiwari");
//array by using ascii values
byte[] arr={115,114,113,50,97,98,100,101};
String s3=new String(arr);
String s4=new String(arr,1,4);
System.out.println(s3);
System.out.println(s4);
char[] chh={'a','b','c'};
int l=s.length();
char c1=s.charAt(2);
//concatinating two strings
String str="mohit";
String s2="sharma";
String result=str.concat(s2);
String substr=str.substring(1);
System.out.println(substr);
System.out.println(result);
StringBuffer strbuff=new StringBuffer();
strbuff.append("hello");
strbuff.append("guys");
String s=strbuff.toString();
}
}