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
Methods:
 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.

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 4 Years Ago by NormR1

This article has been dead for over six months. Start a new discussion instead.