Problem je v tom, ze mate nespravne napisany
konstruktor. Konstruktor nema mat navratovy typ.
Namiesto
public void GenPasswd(){
...
}
pouzite toto:
public GenPasswd() {
...
}
S pozdravom
Radovana Straube
--- [EMAIL PROTECTED] wrote:
> Dobrý den
>
> nejspí¹ je to ¹kolácká otázka, ale zajímalo, by mì
> proè objekty vytvoøené v konstruktoru vrací v
> metodì void generate() null.
> tøídu potom volám takto:
> String passwd = new GenPasswd().generate();
>
> Dìkuji Tomá¹ Jurman Znojmo
>
> Moje tøída:
> /**
> * Generate random string
> */
> public class GenPasswd {
>
> //--------------------------------------Instance
> constans
> private final int LENGTH = 8;
>
> // --------------------------------------Instance
> variable
> private Random rnd;
> private StringBuffer passwd;
> private int number;
>
> // --------------------------------------Constructor
>
> public void GenPasswd(){
> rnd = new Random();
> passwd = new StringBuffer();
> }
>
> // --------------------------------------Other
> methods
> /**
> * @return String passwd
> */
> public String generate(){
>
> for(; (passwd.length() < LENGTH); ){
> // ZDE
> je první vyjímka NullPointerException
>
> number = rnd.nextInt(123);
> // ZDE je druhá
> vyjímka NullPointerException
>
> if (((number > 49) && (number < 57)) || ((number
> > 65) && (number < 90)) || ((number > 97) && (number
> < 122))){
> passwd.append((char)(number));
>
> }
> }
>
> return passwd.toString();
> }
> }
>
____________________________________________________________________________________
Sick sense of humor? Visit Yahoo! TV's
Comedy with an Edge to see what's on, when.
http://tv.yahoo.com/collections/222