+ 3
My code has no output for some reason i was thinking it was part of the if statements but after countless changes i dont know.
In the last case at the bottom I was trying to make it to where the user inputs the case then which method to use for the random password and they choose 2 to combine it and make a random password and they choose how long the password is. https://code.sololearn.com/c126hCzRL0sB/?ref=app
6 ответов
0
I see but what is the difference between using (mmm.equals(sss)) rather than (mmm == sss)
0
I see now my only question is what does the InnerSwitch do on lines 124 and 120, my assumption is that it calls the innerSwitch method but what about the input and type why do we have to place it at the bottom of case 'option 18'?
0
So the scanner is in the innerSwitch method to read for the String cases and differ from the cases I think I understand now thanks for cleaning things up, my overall goal was to erase as much lines as I could and make the code more short without changing the function or purpose of it.
- 1
I'm thinking this is closer to what you are looking for. option 18 isn't working correctly, but now outputs.
https://code.sololearn.com/cPlbEfHet794/?ref=app
- 1
== and != work on object identity. While the two Strings have the same value, they are actually two different objects.
https://stackoverflow.com/questions/8484668/java-does-not-equal-not-working
- 1
My assumption was that you wanted the user to be able to select all of the options and your random case to use the ones listed. In order for both of those thing to happen, I created a function with the shared ones and called it from the default case plus the random case.
The second method would have been to place an if before the switch. It would test for 'random case' performing the selection and updating type to contain the random option. Then the orginal switch could work.
I needed to pass the option from either type or cases to the function for it's switch statement. Since the switch cases needed to read from the scanner, it had to be passed in also.
One additional side note, you really don't have to worry about making your names as unique as you are doing. All of your password variables don't need the number. Only one case runs within the switch scope so there isn't a naming conflict. Same is true for all of the other variables so single 'first' and 'second' could be input into and used.