i can't find a problem with this code, tbh im super new to java

Started by Otakuholic on

Topic category: User side tutorials

Joined Mar 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
i can't find a problem with this code, tbh im super new to java

i keep getting errors but i dont really understand the problem(mostly with the print):

 

public class Quirks {

List quirks = new ArrayList("One for all", "Explosion", "Dark shadow", "Half hot half cold", "Eraser", "All for one", "Engine", "Decay", "Zero gravity", "Frog", "Giantifcation", "Eletrifacation", "Sugar rush", "Hardening", "Navel laser", "Sticky balls", "Acid", "Vine", "Copy");

 

String quirk = obj.getRandomElement(quirks);

 

System.out.println("Your quirk is " + quirk );

Joined Mar 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
still getting closer  …
Fri, 03/29/2019 - 03:09

still getting closer

 

Import java;util.Random    
    
List quirks = new ArrayList<String (Arrays.asList("One for all", "Explosion", "Dark shadow", "Half hot half cold", "Eraser", "All for one", "Engine", "Decay", "Zero gravity", "Frog", "Giantifcation", "Eletrifacation", "Sugar rush", "Hardening", "Navel laser", "Sticky balls", "Acid", "Vine", "Copy"));

Random rand = new Random();

int randIndex = rand.nextInt(quirks.length);

System.out.println(quirks[randIndex]);

  }
}

Joined Nov 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
What exactly do you want…
Sun, 04/07/2019 - 18:32

What exactly do you want your code to do???

Also put it under help next time.

Joined Nov 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
If you don't want help fine.
Sun, 04/14/2019 - 12:53

If you don't want help fine.