The first day of Java learning

Source: Internet
Author: User
Tags instance method

Helloworld.java

Class HelloWorld {

Public HelloWorld () {

}

public static void Main (string[] args) {

Learn2.classmethod (); Invoking other class class methods

learn2 change = new learn2 (); Create an object (instance)

Change.examplemethod (); Calling other class instance methods

Classmethod ();//Call itself Class class method

HelloWorld self = new HelloWorld ();

Self.mymethod ();//Call itself class instance method

}

public static void Classmethod () {

System.out.println ("Call Your own class method (static method)");

}

public void MyMethod () {

System.out.println ("Invoke own class instance method");

}

}

Learn2 class

public class Learn2 {

public void Examplemethod () {

SYSTEM.OUT.PRINTLN ("Call other class method (instance method, need new object to be called)");

}

public static void Classmethod () {

SYSTEM.OUT.PRINTLN ("Call other class static methods (class methods, which can be called directly with the class name)");

}

}

The first day of Java learning

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.