Java Programming For Beginners: Step By Step Lesson #3 || Learning The Basic Terms Used In Java P. & Creating Our First Program Step By Step (By @kaffy22 - The Code Girl)

in #utopian-io7 years ago (edited)

What Will I Learn?

  • You will learn the basic terms used in Java Programming in a very easy and simple way
  • You will learn how to create your first program with every detail

Requirements

  • Computer system
  • JDK must be installed
  • Eclipse IDE

Difficulty

  • Basic

Tutorial Contents

Welcome back! today, we're gonna start writing our first Java Application programs. Doesn't that sound great? Sure it does!

You can quickly check a recap of our last lesson here

Let's get to it guys!

We already created a new class which we named "HellowWorld" in our previous lesson. So we are starting from there.

  • Basic terms used in Java programming and their meanings

Before writing our first program, I'm going to show us some basic terms that we must understand in Java programming. Understanding these terms and their usage will help us greatly in interacting with them and coding in Java generally. Please follow me.

  • Comment
    Comment in programming is used to write statements that are not executable by compiler in a program. Comments are used by programmer to explain what a line of codes mean or to denote some codes. It helps a programmer understand where he is when next he continues coding. There are 3 types of comments in Java programming. They include
  1. In-line/single line comment: Used to comment on a single line withing a program
  2. Multi-line comment: Used to comment on multiple lines withing a program code.
  3. Documentation comment: This is used to make documentation API for a program.
  • Assign
    To set a data for a variable (this involves the use of equal sign).

  • Class
    A class in java simply means a template for creating different objects which defines its properties and behaviours. Literally, A class houses objects, and the properties of this class define the objects.

  • Constructor
    A constructor is a special type of instance method that creates a new object. They have the same name with their class and don't return any value in their declaration.

  • Declaration
    This is a statement that is used to create a variable, thereby identifying its attributes such datatype within a program.

  • Definition
    This is same as declaration, but it reserves some values for variables unlike declaration.

  • Fields
    A field in Java is a class or an interface with an associated value. The values of such class can be called upon at any time within the program.

  • Garbage Collection
    This is an inbuilt memory management that terminates objects that are no longer usable in a program. This is a sweet part of Java programming.

  • Initializer
    A set of code that are executed whenever an instance of a class is created. It is an assignment that sets a starting value of a variable.

  • Method
    Methods in Java are named codes that can be invoked (called upon) anytime within a program. Think of a method as a subprogram that acts on data and often returns a value.

  • Objects
    Like I said above, everything within a class in Java is regarded as objects. Objects have their distinct properties and behaviors based on the class.

  • Parameters
    A parameter simply means a variable or an object passed in a method.

  • Primitive Datatype
    These are basic datatypes in Java programming. They are 8 in total. See them listed below.
    Boolean, byte, char, float & double, int, long and short.

  • Typecast
    Type casting is used to convert an object or variable of one type into another.

  • Variable
    A variable in java has a value and datatype. The datatype determines the kind of entity it can store.

That's all for now. These basic terms listed above are very essential in Java programming. There are still what we call keywords (reserved words) that are used in Java programming. They are not allowed to be used as variables because they are reserved words used by the compiler itself. I'll be talking about that in the next lesson.

  • Creating a "Hello World" app, our first Java program

"Hello World" is mostly used to run first Java program by budding programmers. How about we take a look at how its done.

We already created a class named "HelloWorld" in our previous lesson and here's what we have below.

class 4.jpg

Now we just have to remove the codes above and insert these:

/*
*Our first Java program
*Hello World program
*This program displays "Hello World!" to the output window.
*/
package FirstPrograms;
public class HelloWorld {
public static void main(String[] args) {
System.out.println ("Hello World!");
}
}

After that, hit Run at the top menu and the program runs.

See screenshots below.

run.jpg

hello2.jpg

Behold guys, we've just run our very first Java program! So sweet, isn't it!?

Now let me explain each line of the codes we just wrote above.

/*
*Our first Java program
*Hello World program
*This program displays "Hello World!" to the output window.
*/ //The above lines are comments.
package FirstPrograms; //declaring our package
public class HelloWorld { //class definition header
public static void main(String[] args) { //Main method
System.out.println ("Hello World!"); //print statement
} //end method main
} //end class

That's it guys. You can also create some sample programs using this step. In the next class, we'll talk aboutJava Keywords and write some programs as well.


Like I do tell you guys, programming is not hard, programming is not easy, your approach determines which of its side programming shows to you - easy or hard


Be sure to leave a comment and upvote. A resteem is also appreciated.

Curriculum



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Your contribution cannot be approved because it does not follow the Utopian Rules.

Hi, these are the reasons your contribution was rejected

  • The linked repository is wrong, make sure to choose the repository of the project your tutorial is about and not your own repository; for general Java tutorials please use the repository https://github.com/dmlloyd/openjdk.
  • Tutorials about basic programming concepts (variables, operators, loops, etc.) will not be accepted.

I recommend you read the rules before contributing again in the future.

You can contact us on Discord.
[utopian-moderator]

Thanks for the helpful tips for newbies, I'm new to Java and any information would be helpful to me in my learning. I am a college student in the computer science department and I don't always have the time to learn all the programming languages. I was looking for a solution to this problem and found a service where you can contact experts from https://www.programmingassignment.net/java-assignment-help/ who will help you quickly learn the Java language and become a competent specialist

Coin Marketplace

STEEM 0.20
TRX 0.25
JST 0.038
BTC 96601.54
ETH 3445.82
USDT 1.00
SBD 3.09