Docsity

Java Coding Tutorial, Slides of Computer Programming

Partial preview of the text

Download Java Coding Tutorial and more Slides Computer Programming in PDF only on Docsity!

Coding Basics: Java for

Beginners

https://www.udemy.com/course/coding-basics-java-for-beginners/?re^ Full mini course: ferralCode=B445F3B40D6F25B5EC2C

What is Java?

Java is a programming language and software platform used in computers, mobile devices, applications, game consoles, and even supercomputers. It’s free to download and has a large collection of free tools. High-quality frameworks, or code presets that can be used as templates for different applications.

Key Terms

Source code: The instructions in a program Compile: To translate a program from one language to another. Byte Code : The JAVA Compiler converts code into byte code that runs on multiple computer types. Console: Text box that prints a program’s output. System.out.println is a statement that prints a line of output on the console. Adding (“a”) prints a blank line.

Operators

Bitwise Operators

Bitwise OR (|): Returns bit by bit OR of input values, i.e., if either of the bits is 1, it gives 1, else it shows

Bitwise AND (&): Returns bit by bit AND of input values, i.e., if both bits are 1, it gives 1, else it shows 0. Bitwise XOR (^): Returns bit by bit XOR of input values, i.e., if corresponding bits are different, it gives 1, else it shows 0. Bitwise Complement (~): Returns the one’s complement representation of the input value, i.e., with all bits inverted, which means it makes every 0 to 1, and every 1 to 0.

Conversions

Hexadecimal: Divides patterns into four bit groups. 1 group= 1 symbol Two’s complement: First copy the bits from right to left unti; you reach 1 then find the oppositeof the remaining bits.

Example: 0110= Kilobyte: 2 10 bytes=1024 bytes Megabyte: 2 10 bytes=1,048,576 bytes Gigabyte: 2 10 bytes=1,073,741,824 bytes

Variables

A variable is a name given to a command. Lower case data types are primitive.Upper case types are not. To declare or assign a variable, you must make a declaration statement or an assignment. Declaration statement: int b= Assignment; int b; b= If you declare int b= 20 andthen type System.out.println(b), the output would be

Integer division and other operations

When dividing integers the result is an integer. For example the integer quotient of 14/4 is 3. The remainder of 14/4 is 2. Sometimes calculations can be off because the computer represents real numbers imprecisely. When using an integer and a real number, the result is a real number.

  • (Multiplication): Multiplies values on either side of the operator. / (Division):Divides left-hand operand by right-hand operand.
  • (Subtraction): Subtracts right-hand operand from left-hand operand
  • (Addition): Adds values on either side of the operator. % (Modulus): Divides left-hand operand by right-hand operand and returns remainder.

Comments and Strings

Comments

Comments are used to describe or clarify a code. They are typed in source code. To start a comment, type /* before adding any text you want. Type / to end the comment. Example: /This is a comment*/ If you type // before writing text, you will create a single-line comment. Example: //Single line comment

The End

Hope you enjoyed!