package array1;
import javax.swing.*;
import java.util.Random;
class pickrand{
Random rand = new Random();
public static String get(String[] array){
int rnd = rand.nextInt(array.length);
return array[rnd];
}
}
/*********************************************************************/
public class Array1 {
public static void main(String[] args) {
int size = 10;
String[] passcheck = new String[size];
String[] pass = {"abc345", "7865bn", "987ghw", "234hjg", "060j34", "likh33", "magg33", "alp335", "kawr87", "78j234" } ;
String ret = pickrand.get(pass);
JOptionPane.showMessageDialog(null,"your password is: \n" + ret);
}
}
`
iam new in java and facing problem with non-static variable try to help me thnx......
error is this
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - non-static variable rand cannot be referenced from a static context
at array1.pickrand.get(Array1.java:8)
at array1.Array1.main(Array1.java:20)Inline Code Example Here
`