I am trying to start this java program using the requirements below, but I have no idea where to start. Just so you guys know, I am just starting out in this language. i have experience in Javascript programming, but this is completely different.

I am used to Java programs only having one class, but three? Also, the methods that I am required to use. I have a program design book, but I am not seeing these methods.

I thought writing the classes individually and going from there would work, but no joy.

Here are the requirements for the program:
Write a program that consists of three classes. The first class will be the actual program.

The second class will simply convert a string to lower case.

The third class will have three methods:

public static String trimmed(String str)


public static String trimmed(String str, int len)


public static String squeeze(String str)

The 1st trimmed method will return str without leading or trailing whitespace and will return an empty string if str is null.

The 2nd trimmed method will return the first len characters after trimming the string. The 2nd method must make use of the 1st method.

The squeeze method will replace all sequences of 2 spaces with 1 space.

The program will read a file containing the data below (cut and paste it into notepad and save it), and will display each line:

as entered but trimmed and squeezed.
as entered but trimmed, squeezed, and shortened to 10 characters
as entered but trimmed, squeezed, converted to lower case, and shortened to 20 characters.
Data (copy after this line down to (not including) the line that says end data, you will have 5 lines):
This is a test, this is only a test!

This test is a test of your Java programming skills!
end data

Any assistance would be greatly appreciated.

6 Years
Discussion Span
Last Post by Radio2006

Just declare the classes with the methods described. Then in the first class have your main method and call the other methods. Study how you create classes, declare methods and call them.
You will also need the help of the java API:

For the second class:

public class LowerCase {
   public static String convertToLowerCase(String input) {
      if (input==null) return "";
      return input.toLowerCase();

The 'toLowerCase' method is a method of the String class you can call.

Then in the main method of the first class call it:

String s1 = "ABC";
String s2 = LowerCase.convertToLowerCase(s1);

The names of the classes, methods are random. You can call them anyway you want. Just make sure the class name matches the file name of the class.

Similar you will do the third class with the methods described and the help of the API

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.