Question
String Play (JAVA BEGINNER) Implement the following methods: // Write a method that returns true if s has leading or trailing whitespace, false otherwise public
String Play (JAVA BEGINNER)
Implement the following methods:
// Write a method that returns true if s has leading or trailing whitespace, false otherwise
public static boolean needsTrim(String s)
// Write a method that swaps the first three and last four characters of s
public static String swap3For4(String s)
// Write a method that has one String parameter, and returns true if the first half and last half of the parameter are the same ignoring case, and false otherwise. (The name of the method is up to you.)
Use these methods to rewrite the corresponding parts of the attached StringPlay program.
import java.util.scanner public class StringPlay public static void main(Stringt1 args) System.out.println("Enter a line of text: " String aLine = kybd.nextLine(); if (aLine.trim).equals (aLine)) System.out.println("The original String has no leading or trailing whitespace") h else t System.out.println("The original String has leading or trailing whitespace" String swapped aLine.substring(aLine.length) - 4) + aLine.substring(3, aLine.length) - 4) + aLine.substring(0, 3); System.out.println("First 3 and last 4 chars swapped: " + swapped) int midPoint-aLine.length) / 2; String firstHalf aLine . substring(0, midPoint); if (aLine. length ( ) % 2-1) midPoint++; String secondHalf - aLine.substring(midPoint); system.out.println("Does the first half equal the last half?" + firstHalf.equalsIgnorecase(secondHalf)) the last halfStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started