I need help please send me reply:
Write a program "if given a string like 'HAT', the
combination's returned should be like ATH,THA,TAH in java"?
Answer Posted / sathish.pk
public static void main( String[] args )
{
/* you give any String */
String myString="HAT";
char[] characters=new char[3];
for(int i=0;i<1;i++)
{
for(int j=0;j<=2;j++)
{
/* getting each character from above string(myString)*/
characters[j]=myString.charAt(j);
}
/*print each character according to our output*/
System.out.println(characters[i+1]+""+characters[i]+""+characters[i+2]);
System.out.println(characters[i+1]+""+characters[i+2]+""+characters[i]);
System.out.println(characters[i]+""+characters[i+2]+""+characters[i+1]);
System.out.println(characters[i+2]+""+characters[i+1]+""+characters[i]);
System.out.println(characters[i+2]+""+characters[i]+""+characters[i+1]);
}
}
| Is This Answer Correct ? | 2 Yes | 1 No |
Post New Answer View All Answers
What is a null class?
Difference between ‘>>’ and ‘>>>’ operators in java?
What is the purpose of the strictfp keyword?
Which variable is the independent variable?
what is meant by Byte code concept in Java?
What is the range of a character variable?
Is static a keyword in java?
Explain different states of a thread in java?
What design pattern you have used in your project? I answered Factory pattern, how it is implemented? What are its advantage? Do know about Abstract Factory?
What is the multi-catch block in java?
What is linked hashset and its features?
Can we override singleton class?
Variables used in a switch statement can be used with which datatypes?
How many bits is a string in java?
Is a method a function?