#Head First Java / Java books
1 messages · Page 1 of 1 (latest)
<@&987246399047479336> please have a look, thanks.
Here is an AI assisted attempt to answer your question 🤖. Maybe it helps! In any case, a human is on the way 👍. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.
The 2nd edition of Head First Java is generally recommended as the best edition for beginners. It is praised for its clear explanations and exercises that help solidify understanding of Java concepts. While the 3rd edition may have some negative reviews, it still contains valuable information and can be a helpful resource for learning Java. Ultimately, the best edition for you may depend on your learning style and preferences. Consider checking out both editions to see which one resonates with you more.
I'm doing Mooc fi right now alongside watching Bro Codes 12 hour java course
I'm just looking for a list of good progressive books that teach and/or have lots of exercises
Head First Java / Java books
The third edition's fine. A fourth edition to bring it fully up to date would be nice, but it's one of the best beginner books so far.
Bro codes is a pretty bad resource.
I'm basically doing mooc java and then watching some of that bro code video before sleeping to refresh knowledge
not really the main source of learning
I just saw him teaching though
int example = scanner.nextInt(); (off memory I think)
and mooc teaching
int example = Integer.valueOf(scanner.nextLine());
any difference or what I should prefer?
imo the mooc method seems better and doesn't have that error when a integer scanner comes after a string scanner
His version's wrong:
Mixing any nextXXX method with nextLine from the Scanner class for user input, will not ask you for input again but instead result in an empty line read by nextLine.
To prevent this, when reading user input, always only use nextLine. If you need an int, do
int value = Integer.parseInt(scanner.nextLine());
instead of using nextInt.
Assume the following:
Scanner scanner = new Scanner(System.in);
System.out.println("Enter your age:");
int age = scanner.nextInt();
System.out.println("Enter your name:");
String name = scanner.nextLine();
System.out.println("Hello " + name + ", you are " + age + " years old");
When executing this code, you will be asked to enter an age, suppose you enter 20.
However, the code will not ask you to actually input a name and the output will be:
Hello , you are 20 years old.
The reason why is that when you hit the enter button, your actual input is
20\n
and not just 20. A call to nextInt will now consume the 20 and leave the newline symbol \n in the internal input buffer of System.in. The call to nextLine will now not lead to a new input, since there is still unread input left in System.in. So it will read the \n, leading to an empty input.
So every user input is not only a number, but a full line. As such, it makes much more sense to also use nextLine(), even if reading just an age. The corrected code which works as intended is:
Scanner scanner = new Scanner(System.in);
System.out.println("Enter your age:");
// Now nextLine, not nextInt anymore
int age = Integer.parseInt(scanner.nextLine());
System.out.println("Enter your name:");
String name = scanner.nextLine();
System.out.println("Hello " + name + ", you are " + age + " years old");
The nextXXX methods, such as nextInt can be useful when reading multi-input from a single line. For example when you enter 20 John in a single line.
I see, thanks. Is there another channel you know and recommend?
a mix of visual and reading I think is better for me
also if not already, there should be a tag such as "resources" that displays Beginner/intermediate/advanced books/online workspaces such as mooc and videos
The official Java channel's also useful, Josh Long, Dan Vega, etc..
We have #today-i-teach and #resources .
I guess
but it's a bit all over the place
thanks for the help though
will get my hands on this book sometime and check out those channels
@sudden goblet
Your question has been closed due to inactivity.
If it was not resolved yet, feel free to just post a message below
to reopen it, or create a new thread.
Note that usually the reason for nobody calling back is that your
question may have been not well asked and hence no one felt confident
enough answering.
When you reopen the thread, try to use your time to improve the quality
of the question by elaborating, providing details, context, all relevant code
snippets, any errors you are getting, concrete examples and perhaps also some
screenshots. Share your attempt, explain the expected results and compare
them to the current results.
Also try to make the information easily accessible by sharing code
or assignment descriptions directly on Discord, not behind a link or
PDF-file; provide some guidance for long code snippets and ensure
the code is well formatted and has syntax highlighting. Kindly read through
https://stackoverflow.com/help/how-to-ask for more.
With enough info, someone knows the answer for sure 👍