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 printwriter in java?
What is generic type?
What is charat ()?
what are the disadvantages of indexes in oracle?
Why is singleton class used?
What are the advantages of unicode?
When will you define a method as static in Java?
Is set sorted in java?
Explain the usage of this with constructors?
Can we define static methods inside interface?
What are the different types of garbage collectors in java?
Why do we need hashmap in java?
Is alive in java?
What is the current version of java?
What is use of valueof () in java?