I need to create a program that uses the String classes to read the suffix .txt and if true, return the sentence inputted, but if false return another sentence.
I'm unsure of which boolean method I will need to use to execute this. Can anyone help me? Here is my code so far:
public static void main(String[] args) {
String firstin, secondin, actual = ".txt";
boolean suffix;
Scanner scan = new Scanner(System.in);
System.out.println("Please enter file name and description: ");
firstin = scan.next();
secondin = scan.next();
suffix = firstin.endsWith(actual);
System.out.println(suffix);
How can i return something other than true if true and false if false. For example, if the suffix is .txt, true is returned but i want to replace 'true' with another string visa versa with false.