Java for Beginners, Lesson 14: Bitwise and Shift Operators in Java
Inside the computer every number is stored as a row of bits, each 0 or 1. For example, 12 is 1100. Bitwise operators work directly on these bits, one position at a…
Inside the computer every number is stored as a row of bits, each 0 or 1. For example, 12 is 1100. Bitwise operators work directly on these bits, one position at a…
Programs need to make decisions: is the student’s mark above 40? Is the user’s age between 18 and 25? Relational operators compare two values, and logical operators…
An operator is a symbol that tells Java to do a calculation or a comparison. The values it works on are called operands. In a + b, the + is the operator and a and b…
This lesson covers two things that cause many small mistakes: escape characters (how to print quotes, tabs and new lines) and variable scope (where a variable can be…
A program that always prints the same answer is not very useful. Real programs ask the user for data: a name, a marks list, an amount. In Java, the easiest way to…
Pouring water from a small glass into a big jug always works. Pouring a big jug into a small glass may spill. Java treats numbers the same way. Moving a value into a…
Think of containers: a tiny spice jar, a water bottle and a big drum. You choose the container to match what you store. A variable is the same. The data type decides…
Think of labelled jars in a kitchen: sugar, salt, rice. You do not say “the white powder on the second shelf”. You say “sugar”. A variable is a labelled jar for a…
Every language has three basic things: notes for people, names for things, and reserved words with special meaning. In Java these are comments, identifiers and…
The first program looks small, but it contains the skeleton of every Java program you will ever write. Learning it line by line is like learning the parts of a…