About Hello Java World's understanding (initiator to)

zhaozj2021-02-16  46

A few weeks ago, because of the work needs to start learning Java, although there is already C 's skill, but the learning process is mixed in the process, and it is the simplest Hello World. This example is too simple, so that no one is willing to talk more about the basics of this aspect and comparison with C . Moreover, there is no one in the Hello World example that I have seen, and I will take out a Hello World routine that I have rewritten, and talk about my understanding (written in the comment).

:) Although this example is very simple, I hope that editing can be passed, and the masters also step on a few feet. . .

// filename: hijava1234.java

/ * * Creation Date 2004-5-14 * This file is generated by Eclipse Version 2.1.3 template * Change the generated file template to * Window> Preferences> Java> Code Generation> Code and Note * /

/ ** * @Author administrator * * Change the template for the generated type annotation to * Window> Preferences> Java> Code Generation> Code and Comments * /

Class Hijava // Many textbooks believe that the class containing main () must declare as public, but also to the same name with the file name, in fact, it is not necessary (but still recommended). {Public static void main (String [] args) // Guess, the method declared to static is actually the function of C {System.out.Println ("IT's in hijava main ();");

// system.out.print ("Objt.tostring () ="); // system.out.println (hijava.tostring ()); // system.out.print ("objt.hashcode () =") ; // system.out.println (hijava.hashcode ());

SYSTEM.OUT.PRINTLN ();

Hijava.getStatus ();

} // This, even if the class is not initialized, it can be used in the way, but the access to members cannot be casual, unless the member is static //. Of course, because I don't know if there is any initialization, I can't Use this to access. Originally, the main should be written outside, but there is no mistake in the statement that is declared as public //, because such classes are only allowed in one .java file.

String title = "hijava sample"; // C can not be assigned to the initial value, here is just the opposite

Hijava (String Instring) {system.out.println ("Hijava Init ..."); System.out.Println (Instring); System.out.println ();

Static hijava hijava = new hijava ("Hi My JavaWorld."); // Of course, if you want to assign the initial value to the member, it may cause an instance initialization // If you are commented, it will be less initialization information. But main () will be executed. That is, the entrance function is not affected by the initialization it is // in other words, I think the way to declare static is actually a function that can be performed at any time, although specify its name domain, / / Just like System.out.println ("ABC"); Gogo Gogogo = New Gogo (this); // In Java, because there is no declaration or not, although this class has not been defined, it is already available here.

Void doing () {system.out.println ("Nothing But Just Confuse About!");

INT getStatus () {system.out.print ("this.tostring () ="); system.out.println (this.tostring ()); system.out.print ("this.hashcode () ="); System.out.println (this.hashcode ()); system.out.println (this.title); system.out.println (); this.doing (); // In the instance, you can use this to call this The members of the class. / / May wish to make a hypothesis if the doing () method is defined as static, this.doing () access method will give a warning message Return 1;}

}

Class Gogo {Java.lang.Object Owner; // Specifies the owner's way is the gogogo (java.lang.object owner) of C Builder {Owner = Owner; dosomething (); Return;} void dosomething ()} System.out.println ("why ?? / n"); system.out.print ("Owner.class ="); system.out.println (Owner.getClass () "/ n"); // Use This method can get the Class type return of the parent object;}

}

Laterness:

In addition, when choosing a compilation environment, I listened to the advice from my friends and used Eclipse. After the trial, the feeling is great (referring: J Builder 9), so it is also recommended to try it out to beginners. However, Er, of course, this is your freedom. Attach: Eclipse 2.1.3 Installing Chinese Language Support

Title: Eclipse 2.1.2.1 Chinese language package installation

· This installation instruction festival is selected from the 9CBS article "Eclipse plugin development series (1): Eclipse and its language pack download and installation"

· Eclipse version is not necessarily corresponding to 2.1.2 can also be 2.1.3

· Install the Chinese language support package to download the following files. Eclipse2.1.2.1-sdk-win32-languagePackfeature.zip To download, please refer to: http://eclipse.cis.sinica.edu.tw/downloads/index.php Decompression After the name is LanguagePack (2.xx) Note To keep the Eclipse subdirectories inside, then copy the entire directory to the main directory of Eclipse

· In order to enable the development environment to recognize the language development kit, create subdirectories LINKS, Links under the Eclipse home directory, LANGUAGE.LINK text content: path = languagepack (2.1.2), that is, the name of the directory just decompressed. And restart the Eclipse development environment After restarting, the development environment prompts the new feature to install, click Finish.

转载请注明原文地址:https://www.9cbs.com/read-24596.html

New Post(0)