Write a program in java to demonstrate append() method?

  class StringAppend {                 public static void main(String arg[])                 {                                 StringBuffer s1=new StringBuffer(“Vikrant “);                                 StringBuffer s2=s1.append(“Kumar”);…

Read More

Write a program in java to demonstrate substring() and charAt() method?

class StringSub {                 public static void main(String arg[])                 {                                 String s=”india”;                                 System.out.println(s.substring(1,4));                                 System.out.println(s.charAt(2));                 }…

Read More

Write a program in java to demonstrate startsWith() and endsWith() methods?

class StringWith {                 public static void main(String arg[])                 {                                 String s=”india”;                                 System.out.println(s.startsWith(“i”));                                 System.out.println(s.endsWith(“i”));                 }…

Read More

Write a program in java to find out given string is palindrome or not?

import java.util.Scanner; class Palindrome {                 public static void main(String arg[])                 {                                 Scanner in=new Scanner(System.in);                                 System.out.print(“Enter Word…

Read More

Write a program in java to demonstrate toCharArray() method?

class StringToChar {                 public static void main(String arg[])                 {                                 String s=”India”;                                 char a[]=s.toCharArray();                                 for(int i=0;i<s.length();i++)…

Read More

Write a programmer in java to demonstrate indexOf() and lastIndexOf() method?

class StringIndex {                 public static void main(String arg[])                 {                                 String s=”india”;                                 System.out.println(s.indexOf(‘i’));                                 System.out.println(s.lastIndexOf(‘i’));                 }…

Read More

How many objects will be created in this case string s=”ab”+”cd”+”ef” in java?

class NumberOfObjects {                 public static void main(String arg[])                 {                                 String s=”ab”+”cd”+”ef”;                                 //Number of Objects = 5…

Read More

Write a program in java to demonstrate compareTo() method?

import java.util.Scanner; class StringCompare {                 public static void main(String arg[])                 {                                 Scanner in=new Scanner(System.in);                                 System.out.print(“Enter First…

Read More