Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(InJava) Using Boolean Zen, write an improved (simplified) version of the following method, which returns whether the given String starts and ends with the same

(InJava) Using "Boolean Zen," write an improved (simplified) version of the following method, which returns whether the given String starts and ends with the same character: (2-credit)

public static boolean startEndSame(String str) {

if (str.charAt(0) == str.charAt(str.length()-1)) {

return true;

} else {

return false;

}

} // end of startEndSame()

To submit, write a class, TestWords, which contains main() and startEndSame(). The main() method should call startEndSame() method as follows:

within main(),

System.out.println("\"pop\" returns " + startEndSame("pop"));

System.out.println("\"top\" returns " + startEndSame("top"));

System.out.println("\"erase\" returns " + startEndSame("erase"));

System.out.println("\"stars\" returns " + startEndSame("stars"));

... // test the method with any other words...

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Server Query Performance Tuning

Authors: Sajal Dam, Grant Fritchey

4th Edition

1430267429, 9781430267423

More Books

Students also viewed these Databases questions

Question

Define capital intensity ratio, and explain its significance.

Answered: 1 week ago