Correct modularization and array usage I am trying to brush up on Java after not programming for a few years. The idea behind this code is simply to get used to object oriented programming, modularization techniques, and basic arrays. Any comments and critiques are obviously welcome!

Here is my code: 

/*
 * This code is meant to ask the user for ten sentences,
 * store them in an array, and print that array out one sentence at a time.
 * The goal is to work on modularization and general OOP principles as well as basic arrays and loops.
 */

import java.util.Scanner;

/*
 * ArrayBuilder is a public class that creates an array of ten strings
 * and gives the ability to print them out with the printMessages
 * method.
 */

public class ArrayBuilder{
    //Initialize an array
    public String[] s;

    /*
     * The build method generates ten sentences based on user input
     * and stores them in an array of strings.
     */
    public String[] build(){
        //Create the 10 index array
        s = new String[10];
        //Initialize a scanner object to receive user input
        Scanner scanner = new Scanner(System.in);
        //Loop 10 times asking the user for a new sentence each time
        for (int i = 0; i &lt; 10; i++){
            System.out.println("Enter a new sentence: ");
            //Store the input in the 's' array
            s[i] = scanner.nextLine();
        }
        //Return the 's' array to make it available to the printMessages method
        return s;
    }

    /*
     * The printMessages method loops through a given array and prints the
     * string at each index.
     */
    public void printMessages(String[] s){
        //Loop as many times as there are strings in the list, printing out each index
        for (int i = 0; i &lt; s.length + 1; i++){
            System.out.println(s[i]);
        }
    }

    /*
     * Main method that instantiates an ArrayBuilder object, then calls the 
     * build and printMessages methods to create and display an array of user input.
     */
    public static void main(String[] args){
        //Create a new ArrayBuilder object
        ArrayBuilder AB = new ArrayBuilder();
        //Invoke the build method to build up an array
        AB.build();
        //Invoke the printMessages method to display what is stored in the array
        AB.ptrintMessaages(AB.s);
    }
}
thanks for sharing your code.

here are my thoughts about it:

Naming

Finding good names is the hardest part in programming, so always take your time to think about the names of your identifiers.

avoid single character names / abbreviations

Since the number of characters is quite limited in most languages you will soon run out of names. This means that you either have to choose another character which is not so obviously connected to the purpose of the variable. And/or you have to "reuse" variable names in different contexts. Both makes your code hard to read and understand for other persons. (keep in mind that you are  that other person yourself if you look at your code in a few month!) The same is true for (uncommon) abbreviations. You might find them being obvious today, while you're actively dealing with the problem, but You might have to "relearn" them if you worked on something else for a while.

On the other hand in Java the length of identifier names names is virtually unlimited. There is no penalty in any way for long identifier names. So don't be stingy with letters when choosing names.

Choose you names from the problem domain, not from the technical solution.

Since you provided an "academic" example there is not much of a "problem domaine" here tough. I only want to mention it for the records...

Magic numbers

your code has some magic numbers. This are literal values with a special meaning like here:

    s = new String[10];
    //Loop 10 times asking the user for a new sentence each time
    for (int i = 0; i &lt; 10; i++){


You should introduce constants with meaningful names:

    s = new String[ARRAY_SIZE];
    //Loop 10 times asking the user for a new sentence each time
    for (int i = 0; i &lt; ARRAY_SIZE; i++){


Single Responsibility/Separation of Concerns

In your
excample
you mix business logic with user interaction like this:

public String[] build(){
    s = new String[10];
    Scanner scanner = new Scanner(System.in);
    for (int i = 0; i &lt; 10; i++){
         // begin user interaction
        System.out.println("Enter a new sentence: ");
        s[i] = scanner.nextLine();
         // end user interaction
    }
    return s;
}


You should separate that into specialized methods. This would give you the option to move that UI-methods in classes of their own moving your architection foreward to the Model Vew Controller (MVC) Pattern. 

dependency injection

Your class has the Scanenr class as a dependency. You instantiate this dependency within a method that represents your business logic.

You'd better pass in the Scanner instance as a constructor parameter allowing you to exchange the implementation later (maybe with a mock for unittesting your code)

reduce visibility (Interface segaration principle)

All your methods are public but (i guess) non of them is ment to be called by users. By default make all your methods private unless you explicitly want them to be either accessed by other code (public) or be overridden by subclasses (protected).

useless comments

You program has lots of comments. This used to be a desired feature 20 ears ago. 

You should not add comments just for formal reasons. Such comments are useless at best but usually they turn into lies as the code develops because the first coder changing the content might forget to change the comment too and the next coder refuses to change the comment because she does not know if the comment is wrong or the code...




  Could you give an example of how to accomplish what you are talking about under the section "Single Responsibility/Separation of Concerns"? – J. Tate


You could intrioduce a UI interface for your "application" like this:

interface UserInterface{
    String requestElementFromUser();
}


and an implementation for use with the commandline (most likely in its own *.java file):

class CommandLineuserInterface implements UserInterface{
    private final Scanner commandlineInput;
    private final PrintWriter commandlineOutput;
    CommandLineuserInterface(Scanner commandlineInput, PrintWriter commandlineOutput){
      this.commandlineInput= commandlineInput;
      this.commandlineOutput= commandlineOutput;
    }
    @Override
    public String requestElementFromUser(){
        commandlineOutput.println("Enter a new sentence: ");
        return commandlineInput .nextLine();
    }
}


In your code you would inject an instance of this to your class instanc:

public static void main(String[] args){
    ArrayBuilder AB = new ArrayBuilder(new CommandlineUserInterface(new Scanner(System.in), System.out));


Store that in you app:

public class ArrayBuilder{
    //Initialize an array
    public String[] s;
    private final UserInterface userInterface;
    public ArrayBuilder(UserInterface userInterface){
       this.userInterface= userInterface;
    }


and use that in your code:

   for (int i = 0; i &lt; 10; i++){
        s[i] = userInterface.requestElementFromUser();
   }


The benefit here is that you easily can change the implementation of UserInterface to get the elements from a database, a web service or any even a graphical dialog without ever touching this code again.
The only existing code to change is your main method. But tha't OK since the major responsibility of main is constructing the applications object tree.