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
Where are the card layouts used?
What is return keyword in java?
When should we create our own custom exception classes?
What are different types of constants?
What are exception handling keywords in java?
What is the difference between the boolean & operator and the && operator in java programming?
What are implicit objects in java?
What is the difference between overriding & overloading?
What is data type example?
Does java list allow null?
What is enhanced loop in java?
What is the difference between declaration and definition in java?
How are this() and super() used with constructors in java programming?
What is off heap memory?
Is arraylist a class in java?