#assign new variable through a method

5 messages · Page 1 of 1 (latest)

viral ginkgo
#

I have a question, I'm told to do the following.
make a method called assign initialize a new variable from it.

assign: to initialize a new variable and assign a value to it. Example: assign
x y, where x is the variable and y is the value assigned. The value could be
an integer number, or a string

I have wrote something like this but its obviously really wrong, can anyone help on how to do this?

    public void assign(String varType, String varName){

        varType varName = new varType;

    }
glass plankBOT
#

This post has been reserved for your question.

Hey @viral ginkgo! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

vocal trench
viral ginkgo
#

Thank you so much! <3