1 / 4

Java program structure

Here in this article, it has been explained about the Java Hello World scenario with structures and features of class and this code is written to fullfill the task of printing Hello World from Java on the screen.

prachipatil
Télécharger la présentation

Java program structure

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 java programming structure learn java programming structure Here in this article, it has been explained about the Java Hello World scenario with structures and features of class and this code is written to complete the task of printing Hello World from Java on the screen. 1. “package sct”: Given here is a package declaration. This definition of package statement shows a name space in which classes is stored. Package is used to arrange the sessions based on performance. If you bypass the package statement, the course titles are put into the standard system, which has no name. Package statement cannot appear anywhere in system. It must be the first line of your system or you can bypass it. 2. “public class HelloWorld”: This line has various elements of Java development. a. public: This is accessibility modifier keyword and key phrase which informs compiler accessibility to category. Various principles of accessibility modifiers can be community, secured,private or standard (no value). b. class: This keyword and key term used to announce category. Name of class (HelloWorld) followed by this keyword and key term. 3. Feedback section: We can create comments in Java in two ways. a. Line comments: It begins with two forward slashes (//) and proceed to the end of the presentline. Line comments do not have an finishing icon. b. Block comments start with a forward slasj and an asterisk (/*) and end with an asterisk and a

  2. forward slash (*/).Block comments can also increase across as many lines as required. 4. “public fixed gap primary (String [ ] args)”: Its technique (Function) known as core with sequence range as discussion. a. public : Access Modifier b. static: It is arranged keyword which means that a technique is offered and useful even though no things of the course are available. c. void: This keyword and key word states nothing would be a come back from technique. Method can come back any basic or item. d. Method material within wavy tooth braces. { } asdfla;sd 5. Program.out.println(“Hello Globe from Java”) : a. System:It is name of Java application class. b. out:It is an object which is associated with Program class. c. println:It is an application technique name which is used to deliver any String to system. d. “Hello Globe from Java”:It is String actual set as discussion to println method. More Info on Java Class: Java is an object-oriented language, which indicates that it has constructs to signify factors from the actual life. Each Java system has at least one class that knows how to do certain factors or how to signify some kind of item. For example, the easiest class, HelloWorld,knows how to welcome the globe. Sessions in Java may have techniques (or functions) and areas (or features or properties). Let’s take example of Car item which has various qualities like shade, max rate etc. along with it has features like run and quit. In Java globe we will signify it like below: package sct;

  3. public class Car { private String color; private int maxSpeed; public String carInfo(){ return color + ” Max Speed:-” + maxSpeed; } //This is constructor of Car Class Car(String carColor, int speedLimit){ this.color = carColor; this.maxSpeed =speedLimit; } } Lets create a class known as CarTestwhich will instantiate the car class object and contact carInfo way of it and see outcome. package sct; • //For callingCar objects and instantiating it this class is used. • public class CarTest { • public static void main(String[] args) { • Car maruti = new Car(“Red”, 160); • Car ferrari = new Car (“Yellow”, 400); • System.out.println(maruti.carInfo());

  4. • System.out.println(ferrari.carInfo()); • } • } Result of the above CarTest java class is as below. We can run CarTest java system because it has primary technique. Main technique is place to begin for any java system performance. Operating software indicates informing the Java VIrtual Device (JVM) to “Load theclass, then begin performing its primary () technique. Keep running ’til all the code in primary is completed.” Read more about our Java training Institute. You can check our Java reviews.

More Related