DEV Community

loading...
Cover image for First Step to JAVA

First Step to JAVA

DELI
Front End Developer , Web Dev. , AI , AR and Blockchain
・3 min read

Hello my Dazzling friends from the Internet, Here I am presenting the basics of JAVA in this and upcoming blogs and then we will start with the Object Oriented Programming (OOP) . Here we will see the modern day problems in our blog which makes you more clear and clarified . Happy learning Folk's !

JAVA was developed by James Gosling at Sun Microsystems (acquired by Oracle).

Why people Use JAVA ?

=> It is portable (it can be use on any platform for example Windows , Macintosh and linux ).
=> It is easy to learn and use,and also very robust .
=> It is free to use i.e. OpenSource.
=> It is secure and fast .
=> More number of developers around the World !
=> And finally being a OOP , the code can be reused which helps to minimized the Cost in development .

Now without further Ado Lets start with JAVA SYNTAX !

1) Lets Start with our very first program Printing out "Hello My Dazzling friends from the Internet "

package javablogs;

public class Hello {
    public static void main(String[] args) {
        System.out.println("\"Hello My Dazzling friends from the Internet\" ");
    }
}
Enter fullscreen mode Exit fullscreen mode

output:
alt text

Now let's break down the code for analysis :

package

here refers to the group of similar types of classes, sub-packages and also interfaces , there are many packages in JAVA , the most common is utility package i.e. util , Lang, swing , io , sql .

For this duration of time we don't take care about Package much we will discuss it in further blogs as we proceed
but to import any package We say for example utility package then

import java.util
Enter fullscreen mode Exit fullscreen mode

then comes Class :

here class plays the most important role in java program as it is object oriented .
Here each line running in the JAVA code must be in a java class and each java program consist of a main method inside a class

main Method i.e.

   public static void main(String[] args) {
}
Enter fullscreen mode Exit fullscreen mode

Any code inside the main() method will be executed. Here Don't think much about the keywords written before and after the main keyword we will get them to know in the upcoming blogs .

Note :

=> JAVA class name should always be same as the file name for example if my JAVA class name is Hello then my filename should be Hello.java
=> As Java is case sensitive the classname always begin's with a capital letter

Moving on with System.out.println() :

This is used to print the statements to be displayed on the terminal or command line

This is basically invoked out from the PrintStream() i.e. instance , and which is public and static member of System class

hence, remember for now println() is an instance that is taken from PrintStream class .

Comments in java

There are basically two types of comment in java one is Single Line comment in java and second one is Multi-line comment .

Single line comment are written after '\'

and Multiline are used for more than one line and are used as
/* ........
..............
..... */

Single line comments in java

import java.util   // importing the java package utility
Enter fullscreen mode Exit fullscreen mode

Multiline comment in java

package javablogs;

public class hello {
    public static void main(String[] args) {
 /* printing a statement with System.out.println
  and displaying it on terminal */
        System.out.println("\"Hello My Dazzling friends from the Internet\" "); 

    }
}
Enter fullscreen mode Exit fullscreen mode
Note :

Java comments are never seen on command line interface or on terminal cause they are just used by programmer's for information to something they can check when they come back after some different project's . And it can also be helpful to other people working on the same project
I always recommend people to use Comments as they help a lot in future when you look back at code.

Let' s conclude

lets keep up to this ,will learn more things in upcoming blogs next blog will be releasing soon !

Discussion (0)