Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » HELP ME PLEASE (Some basic java)(Help)
icon4.gif  HELP ME PLEASE (Some basic java) [message #1492355] Sat, 29 November 2014 14:54 Go to next message
Eclipse UserFriend
Hey i need some help, this is the code i wrote, and i want now to pop out the rendum string (myNames) i know only how to pop out the string 1, 2 or 3 but can you help me that it pop out randum from 1 to 3! Sorry for my very bad eng! And thanx for help!


final String[] myNames = new String[3];
myNames[0] = " JOKE 1 ";
myNames[1] = "JOKE 2";
myNames[2] = "JOKE 3";

pushMe.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
textOne.setText(myNames[RANDOM]);
Re: HELP ME PLEASE (Some basic java) [message #1497090 is a reply to message #1492355] Wed, 03 December 2014 09:36 Go to previous message
Eclipse UserFriend
You can use Math.random() to generate random number between 0.0 to 1.0, later you can multiply it to 10 or 100 depending upon how many random number you will need, mostly depends upon how many elements you have in your array. Since here you three elements, you just multiply with 3 and cast it to int. For code example, you can take a look here
Previous Topic:Hi guys need help with Trapezoidal Rule Java code
Next Topic:Java Error.
Goto Forum:
  


Current Time: Wed Jul 02 19:59:28 EDT 2025

Powered by FUDForum. Page generated in 0.03313 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top