Java can't save my input. See my code

class History  {

    public String[] history;

    public History(String[] history) {
       if (history == null)
           history = new String[]{};
       else 
           history = this.history
    }

}

It just keep saving null down no matter what i give it.. So can't work with it..

Answers


Don't you mean this?

else this.history = history;

You also have a mistake in this line:

history = new String[]{};

It should be:

this.history = new String[]{};

When I program, I never give local variables the same name as class variables. It only leads to confusion.


Need Your Help

ul alignment issue html

html css table

I have created a list in an html email as

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.