CodeGym /Java Course /Java Syntax Zero /Additional lessons for Level

Additional lessons for Level

Java Syntax Zero
Level 2 , Lesson 9
Available

In this level, you became familiar with the int (integers) and String (text) types, and you delved into the operations you can perform on them. What's more, you learned how to work with data input.

To consolidate this knowledge, you need to complete tasks, of course. But some "reading at home" also won't hurt. Here are some lectures to help you delve deeper into the topics we've covered.

Scanner class

As you already know, this class makes life a little easier for Java developers who get confused by reader classes. It can do a lot, and you've already managed to use it a couple of times. And if you haven't already done so, read the article "Scanner class", study the examples, and try to use the class yourself.

Reading from the keyboard: "readers"

This topic is not always presented to beginners at the outset, because the abundance of incomprehensible words can create confusion. This lesson on reading input from the keyboard provides a little more information than in the course itself. For example, you can learn about what a stream is — an entity you will meet a little later.

Numeric operators in Java

Programming involves many operations on numbers. We'll consider the most important of them and provide examples. How do we perform operations on numbers in Java? There are various ways. There are ordinary arithmetic operations. There are the somewhat less familiar logical operations. And there are bitwise operations, which are completely exotic for non-IT people. It's time to dive into this as well as into operator precedence in our favorite language.


2
Опрос
Types and keyboard input,  2 уровень,  9 лекция
недоступен
Types and keyboard input
Types and keyboard input
Comments (10)
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION
Jesú Level 14, Madrid, Spain
13 October 2023
I don't think we have learned about the Buffered reader so far
curi0usmind Level 9, Switzerland Expert
12 May 2023
10/10
Anonymous #11229118 Level 6, Montréal, Canada
24 December 2022
For once I can be the anoying guy that always gets 99% in a test and is pissed about it ( i got 9\10) I'm anoyed i was so close.
curi0usmind Level 9, Switzerland Expert
29 July 2023
That would be 90% but ok
Mavia Talha Level 4, Pakistan
27 September 2022
Becouse we use int data type for whole numbers so the int data type result is always in integer .we can use double or float for floting pointe.
Badass Bunny Level 4, Australia
9 August 2022
Why the expression 5/2 is 2 instead of 2.5?
Margarita Kholostova Level 4, United States of America, United States
23 August 2022
Because the result of the integer division is integer. Integer can hold only whole numbers. Therefore, the result of integer division also will be a whole number. If you want to get 2.5 result you have to use double or float data type instead.
Patryk Kotański Level 24, Poland
6 December 2022
imo question has been asked wrong way. It was not said it is referring to int, so I also chose 2.5
Hiyo Level 24
11 January 2023
In Java, C++ and many other languages, division between 2 integers will always result in a rounded down ( if it is fractional ) whole number. 5/2 = 2. 5.0f / 2 = 2.5. ( 5 is a float ) 5 / 2.0f = 2.5. ( 2 is a float ) (float)5/2 = 2.5 ( because 5 is typecasted to float, equivalent to 5.0f / 2 ) (float)(5/2) = 2 ( because typecasting result: 2 to float still gives you 2 as it has been rounded down ) Same for double btw.
alexhanson1002 Level 5, United States of America, United States
18 February 2023
in java when dividing integers it always rounds down to the next integer rather than using a decimal because it is an integer and not a float so it can only store integers. (i.e. 1,2,3....)