Get the answers you need at Westonci.ca, where our expert community is always ready to help with accurate information. Join our Q&A platform to get precise answers from experts in diverse fields and enhance your understanding. Our platform offers a seamless experience for finding reliable answers from a network of knowledgeable professionals.
Sagot :
Answer:
Following are the code to the given question:
import java.util.Scanner;//import package
public class OrderStrings // defining a class OrderStrings
{
public static void main(String[] args) //defining a main method
{
Scanner scnr = new Scanner(System.in);//defining a Scanner class object
String firstString;//defining a String variable
String secondString; //defining a String variable
firstString = scnr.next();//input value
secondString = scnr.next();//input value
if (firstString.compareTo(secondString) < 0)//use if to compare sting value
System.out.println(firstString + " " + secondString);//print sting value
else//else block
System.out.println(secondString + " " + firstString);//print sting value
}
}
Output:
rabbits capes
capes rabbits
Explanation:
In this code a class "OrderStrings" is defined inside the class the main method is defined that declares the two string variable that uses the input method to input the string value and after input, it uses the conditional statement. Inside this compareTo method is declared that compare string value and prints the string value.
Thank you for visiting our platform. We hope you found the answers you were looking for. Come back anytime you need more information. We appreciate your time. Please come back anytime for the latest information and answers to your questions. We're dedicated to helping you find the answers you need at Westonci.ca. Don't hesitate to return for more.