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

Started by Otakuholic on

Topic category: User side tutorials

Last seen on 03:08, 29. Mar 2019
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 );

Last seen on 03:08, 29. Mar 2019
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]);

  }
}

Last seen on 03:08, 29. Mar 2019
Joined Mar 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
maybe
Fri, 03/29/2019 - 03:09

maybe

Last seen on 14:43, 2. Aug 2022
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.

Last seen on 14:43, 2. Aug 2022
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.