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
Can we override constructor?
What is an example of a constant variable?
Which browsers work with java?
What does the ‘static’ keyword mean? Is it possible to override private or static method in java?
Is singleton class immutable?
What are alternatives to java serialization?
What is composition in java?
What is an example of a keyword?
What is the purpose of the System class?
Is class forname reflection?
What is locale?
Does sprintf add a null terminator?
What is treeset in java collection?
Is empty set an element of empty set?
How do you bind variables?