Can I put 2 public classes into one Java code?
For example: I need to turn an inputted word backwards, and then the user can ask to print out an individual character.
I have the first part of the code written, where it changes the word to be backwards, but am not sure how to implement the second part of the code within the first.
import java.util.*;
class backwards_string
{
public static void main(String args[])
{
String original, reverse = "";
Scanner in = new Scanner(System.in);
System.out.println("Please enter a word: ");
original = in.nextLine();
int length = original.length();
for ( int i = length - 1 ; i >= 0 ; i-- )
reverse = reverse + original.charAt(i);
reverse = reverse.toUpperCase();
System.out.println("Your word backwards is: "+reverse);
System.out.println("Choose an individual character to print out: ");
}
}
.javafile