Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
import java.io.*;
public class Test {
public static void main(String args[]) {
String Str = new String("Welcome to Tutorialspoint.com");
System.out.print("Return Value :" );
System.out.println(Str.replace('o', 'T'));
System.out.print("Return Value :" );
System.out.println(Str.replace('l', 'D'));
}
}
public class Test {
public static void main(String args[]) {
int x =Integer.parseInt("9");
double c = Double.parseDouble("5");
int b = Integer.parseInt("444",16);
System.out.println(x);
System.out.println(c);
System.out.println(b);
}
}
public class CharAt_IndexOf_Example {
public static void main(String args[]){
String str = "This is tutorialspoint";
System.out.println("Index of letter 't' = "+ str.indexOf('t', 14));
System.out.println("Letter at the index 8 is ::"+str.charAt(8));
}
}
public class Sample {
public static void main(String args[]){
String str1 = "gala";
String str2 = "alag";
String s3 = str1+str1;
if(s3.contains(str2)) {
System.out.println("str1 is rotation of str2");
} else {
System.out.println("str1 is not rotation of str2");
}
}
}
import java.lang.StringBuffer;
public class ToggleReverse {
public static void main(String args[]){
String sample = "Hello How are you";
String[] words = sample.split(" ");
String result = "";
for(String word:words){
StringBuffer s = new StringBuffer(word);
word = s.reverse().toString();
String firstSub = word.substring(0, 1);
String secondSub = word.substring(1);
result = result+firstSub.toLowerCase()+secondSub.toUpperCase()+" ";
}
System.out.println(result);
}
}
import java.lang.*;
public class StringDemo {
public static void main(String[] args) {
String str1 = "This is TutorialsPoint";
// returns canonical representation for the string object
String str2 = str1.intern();
// prints the string str2
System.out.println(str2);
// check if str1 and str2 are equal or not
System.out.println("Is str1 equal to str2 ? = " + (str1 == str2));
}
}
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateString {
public static void main(String args[]) throws Exception{
String date = "21-9-2017";
SimpleDateFormat sdt = new SimpleDateFormat("dd-MM-YYYY");
Date result = sdt.parse(date);
System.out.println(result);
}
}
import java.lang.*;
public class StringDemo {
public static void main(String[] args) {
String str = "tutorialspoint";
//prints length of string
System.out.println("length of string = " + str.length());
//checks if the string is empty or not
System.out.println("is this string empty? = " + str.isEmpty());
}
}