3
LeMeow
7y

!(rant)

I'm a student and I'm currently working on a project.

How do I get it to execute blocks of code depending on the type of value it receives in a variable?

or maybe
Should I just use some other method or workaround to do it?

I'm not sure if I should post my question on SO.
(I think it's a dumb question)

--
If it gets (request.getParameter) a string { execute code }
else if {
//gets an int
execute code
}

Comments
  • 0
    Switch(inputVar)
    Case 0: function0()
    Case 1: function1()

    Etc.
  • 0
    Also if the inputVar is something tricky, you could make a method what returns easier to implement flags example, 1 for int, 2 for char etc
  • 1
    @RazorSh4rk
    The default value is a string. If the user selects a value, it gets an int. :/
  • 1
    @DivineInfinity

    if param instanceof String
    ...
    else if param instanceof Integer
    ...
Add Comment