my dillema is i dont fully understand this assignment. I also dont know if my array should be inside of class or inside of the void setString method. help

import java.util.Arrays;
class String
    //data members
    private int SIZE =  25;
    private  [] myString = new array[25];

    public void setString( String newString )
        String[] setString = new String[newArray.length];

Write a class that performs similar operations as the Java String class.
Use only private data members and public methods.
Do NOT use any existing String methods from the Java String class in MyString implementations. The only
exception is the setString( ) method as described below
Data members:
 array of 25 characters
 size – current number of characters in the array
 void setString( String newString )
Stores newString into the array and sets the value of size. A maximum of 25 characters
can be stored. Use only String methods length( ) and charAt( ) to write this method.

5 Years
Discussion Span
Last Post by NormR1

array should be inside of class or inside of the void setString method.

If you want the contents of the array to be avaiable after execution leaves the method, you should define the array at the class level.
If the array is discarded when the method exits, it can be define inside the method.

Having a variable and a method with the same name can be confusing: setString

Same with using String for the name of your class. Make your class name unique.

Edited by NormR1

This topic has been dead for over six months. 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.