Write a method called newTest(String input) that accepts one input. Input is a string stored as a variable called input and returns nothing back. Method should test to see if the string’s first and last characters are the same and should disregard case. Use a string method that converts to either lower or upper case. Convert the string to its character array and test the first and last characters. If they are the same, print to System.out "same"; else, print "not".

At this point I am struggling to extract the characters and plug them into "if".

public static void main(String[] args) {

        String input = "please help";

        // extract first and last characters here

        if (/* first char */ == /* last char */) {
            System.out.println("same");
        } else {
            System.out.println("NOT");
        }

    } // end of input() method

maybe this one can returs as you wanted

String input = "please help";
        if (input.substring(0, 1).equals(input.substring(input.length() - 1, input.length()))) {
            System.out.println("same");
        } else {
            System.out.println("NOT");
        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.