aspose file tools*
The moose likes Performance and the fly likes random.nextInt + If statements Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "random.nextInt + If statements" Watch "random.nextInt + If statements" New topic
Author

random.nextInt + If statements

john price
Ranch Hand

Joined: Feb 24, 2011
Posts: 495

I am creating a password generator/fake password hacker. Is there a better way to do this?

Thanks,
John Price aka cc11rocks


“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” (Mosher's Law of Software Engineering)
“If debugging is the process of removing bugs, then programming must be the process of putting them in.” (Edsger Dijkstra)
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18842
    
  40

john price wrote:I am creating a password generator/fake password hacker. Is there a better way to do this?

Thanks,
John Price aka cc11rocks


You seem to have a couple of bugs -- such as 22 is assigned to two letters, but I get the gist of what you are trying to do....

Try....



Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
john price
Ranch Hand

Joined: Feb 24, 2011
Posts: 495

It works perfect thanks! Could you please explain this:

Like I understand it but why is this possible? I see
"char = char1 + char2 - int"
Thanks,
cc11rocks aka John Price
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18842
    
  40

john price wrote:
Like I understand it but why is this possible? I see
"char = char1 + char2 - int"


Please take another look again. You'll see that it is something else, and it is valid.

Henry
john price
Ranch Hand

Joined: Feb 24, 2011
Posts: 495

Thanks for your help. Here is the program I came up with:

I'm going to add more JRadioButtons (more password length options), but here it is. It is fully runnable. Thank you very much!
cc11rocks aka John Price
 
Don't get me started about those stupid light bulbs.
 
subject: random.nextInt + If statements