0 | |
By: [email protected] On: Thu Nov 03 07:44:38 IST 2016 0 0 0 | 0 |
Are You Satisfied :0Yes0No |
package com.india.javatpoint; public class Reverse { public static void main(String[] args){ String original="Strings are Immnutable"; String[] reverse; String[] strArr = original.split("\\ "); reverse = new String[strArr.length]; for(int i=0;i<strArr.length;i++){ String charToString = ""; if(i==0||i%2==0){ String temp = strArr[i]; char[] charArr = temp.toCharArray(); for(int j=charArr.length-1;j>=0;j--){ charToString=charToString+charArr[j]; } reverse[i]=charToString; System.out.println("String at index "+i+" is: "+charToString); }else{ reverse[i]=strArr[i]; System.out.println("String at index "+i+" is: "+strArr[i]); } } //print Reverse string as per Output for(int k=0;k<reverse.length;k++){ System.out.print(reverse[k]+" "); } } } | 0 |
By: [email protected] On: Thu Nov 03 14:28:01 IST 2016 0 0 0 | 0 |
Are You Satisfied :0Yes0No |
public class ReverseString { public static void main(String[] args) { String s1="Strings are Immutable"; String strArr[]=s1.split(" "); String str1=strArr[0]; String str2=strArr[1]; String str3=strArr[2]; String strFinal=""; for (int i=str1.length()-1;i>=0;i--) { strFinal=strFinal+str1.charAt(i); } strFinal=strFinal+" "; for (int i=str2.length()-1;i>=0;i--) { strFinal=strFinal+str2.charAt(i); } strFinal=strFinal+" "; for (int i=str3.length()-1;i>=0;i--) { strFinal=strFinal+str3.charAt(i); } System.out.println(strFinal); } } | 0 |
By: [email protected] On: Wed Dec 21 15:53:53 IST 2016 0 0 0 | 0 |
Are You Satisfied :0Yes0No |
public class ReverseString { public static void main(String[] args) { String s1="Strings are Immutable"; String strArr[]=s1.split(" "); String str1=strArr[0]; String str2=strArr[1]; String str3=strArr[2]; String strFinal=""; for (int i=str1.length()-1;i>=0;i--) { strFinal=strFinal+str1.charAt(i); } strFinal=strFinal+" "; for (int i=str2.length()-1;i>=0;i--) { strFinal=strFinal+str2.charAt(i); } strFinal=strFinal+" "; for (int i=str3.length()-1;i>=0;i--) { strFinal=strFinal+str3.charAt(i); } System.out.println(strFinal); } } | 0 |
By: [email protected] On: Wed Dec 21 15:53:53 IST 2016 0 0 0 | 0 |
Are You Satisfied :0Yes0No |