1 / 11

Learn 7 Basics of Java Programming to Start Coding Today

In this post, I will cover 7 basics of Java Programming to help you start coding in Java Today.<br>Before going ahead, I would recommend you go through our blog on How to Learn Java from<br>Scratch, which ensures you have a clear learning roadmap in your mind.

simplivllc
Télécharger la présentation

Learn 7 Basics of Java Programming to Start Coding Today

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Learn 7 Basics of Java Programming to Start CodingToday In this post, I will cover 7 basics of Java Programming to help you start coding in Java Today. Before going ahead, I would recommend you go through our blog on How to Learn Java from Scratch, which ensures you have a clear learning roadmap in your mind. I probably don’t need to tell you that without mastering basics in Java or any programming language, you cannot do coding efficiently. Whether you are a recent graduate who is looking to learn a major programming language like Java or an experienced programmer who wants to increase the potential for future career growth, having a solid knowledge of basic concepts of Java is must. Java is an easy programming language for one who has paid attention to the basics, however, it can be equally frustrating for one who tries to take the shortcut. If any of the above points sounds familiar, I have a great news: There are 7 basics concepts of Java which can help you to start coding better right today. You can also find a list of Java online courses which will cover these basics concepts and their application in detail. Let’s get started with our discussion…. We will cover 7 Java Coding basics elements in the following manner: 1.Basic Program Syntax 2.Variables 3.Datatypes 4.Operators 5.Arrays

  2. 6.Loops 7.Conditional Statements Let’s get started with the first basic. Let us consider a basic sample program in Java, “Hello World” program. 1) Basic Program Syntax: public class MyfirstJavaProgram { public static void main (String[] args) { System.out.println(“Hello World”); } } Let’s see some basic syntax to write this program: 1.Case sensitivity: Java is case sensitive. Here upper case letters and lower case letters are treated completely different. 2.Class name: For all class names the first letter should be in Upper Case. If several words are used in class name each inner word should start with upper case letter. For example, in the above program class name is MyFirstJavaProgram. 3.Method name: Each method name should start with a lower case letter. If more words are included in Method name, then each word should start with Upper case word. For example, method name: Public void myMethodName(). 4.System.out.println(): It is used as a print statement. System is the class, out is the object PrintStream class, println() is the method of PrintStream class. 2) Variables: A variable is used to store the data value. These are associated with data types. There are different types of variables as discussed below: 1.Local variable: A variable is declared inside the body of the method is called as local variables. 2.Instance variable: A variable declared inside the class but outside the body of the method, is called instance variables. 3.Static variable: A variable which is declared as static is called static variable. A static variable cannot be local. It is not possible to create a single copy of the static variable and share among all the instances of the class. Memory allocation for static variable only once when the class is loaded in the memory.

  3. 3) Datatypes: Data types can specify different sizes and values that can be stored in the variable. a) Primitive data types: There are totally eight primitive data types present in Java. 1.Boolean: Boolean hold either true or false information. The default value is false. 2.Char: Char is used to store any character. The default value is ‘\0000’. The default size is 2 bytes. 3.Byte: Byte can hold the numbers in the range of -128 to 127. The default value is 0. The default size is 1 byte. 4.Short: Short can hold the numbers in the range of -32,768 to 32767. The default value is 0. The default size is 2 byte. 5.Int: Int can hold the numbers in the range of -2,147,483,648 to 2,147,483,647. The default value is 0. The default size is 4 byte. 6.Long: Long can hold the numbers in the range of -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. The default value is 0L. The default size is 8 byte. 7.Float: Float is mainly used to save memory in large arrays of floating point numbers. The default value is 0.0f. The default size is 4 bytes. 8.Double: Double is generally used as the default data type for decimal values, generally the default choice. The default value is 0.0d. The default size is 8 bytes. b) Non-primitive data types: Non-primitive data types include Classes, Interfaces and Arrays. 4) Operators: Java provides a rich set of operators. An operator is a character that represents an action. Let us see some of the different operators in Java.

  4. a) Arithmetic operators: b) Assignment operators: c) Logical operators: d) Relational operators: e) Bitwise operators: f) Unary operators: g) Ternary operators: a) Arithmetic operators: Arithmetic operators are used to perform arithmetic operations like addition, subtraction, multiplication, and division.

  5. b) Assignment operator: Assignment operator assigns values to variables.

  6. c) Logical operator: Logical operators operates on boolean expressions. They are used in conditional statements and loops for evaluating conditions. Logical operators in Java are &&, ||, !. d) Relational operator: Relational operator determines the relationship between two operands. It checks whether the operands are greater than, less than, equal to and not equal to, etc. Below table shows the relations between the two operands. e) Bitwise operators: Bitwise operators are used in Java that operates on bits and performs the bit-by-bit operation.

  7. f) Unary operators: Unary operators are used to perform the operation on only one operand. g) Ternary operators: Java ternary operator consists of three operands and it is used to evaluate Boolean expressions. h) Shift operators: There are two shift operators in Java. They are 1.Left shift operators: The left shift operator << is used for shifting all the bits in a value to the left side of a specified number of times. 2.Right shift operators: The Right shift operator >> is used for moving the left operands value to right by the number of bits specified by the right operand.

  8. 5) Arrays: It is a common type of data structure which is a collection of similar type of elements that have a contiguous memory location. Types of Arrays in Java: a) Single dimension array: It is a list of variables of the same type that can be accessed by a common name. b) Multi dimension array: It is a type of array where data is stored in matrix form. 6) Loops: While writing programs sometimes you need to execute a block of code multiple times in order to get the desired result. In such cases, loop statements allow to execute statements or group of statements multiple times which allows to build the software application efficiently. Java comes several types of loop statements to handle looping requirements.

  9. 7) Conditional Statements: Conditionals statements are used to execute a set of statements based on certain conditions. Some of the conditional statements are: 1.If statements: The if statements execute a certain section of code only if a test evaluates to true. 2.Nested if statements: The nested if statements consist of an if statements inside another if statements. 3.If else statements: Here in if else statements if the condition is true, then the section that comes under if would execute else the section of code under else would execute. 4.If else if statements: If else if statement is used to check when there is a need to check the multiple conditions. 5.Switch statements: When the number of choices is more, and we may need to perform a different task for each choice then switch statements are used. Conclusion There are plenty of online Java courses right here at Simpliv which can help you to master these basics. Question for you: Which basics from today’s post are you going to master first OR maybe you would like to add anything to the above list?

  10. Either way, let me know by leaving a comment right below and do share the post on social media if you have enjoyed reading it. Next related article to 3 Components of Java Programming Language

More Related