Static Methods in Java cannot call dynamic methods. How do I call the instance methods in the same class in a class containing main ??

Source: Internet
Author: User
Static Methods in Java cannot call dynamic methods. How do I call the instance methods in the same class in a class containing main ?? Questioner: shibotian | views: 1926
Isn't main a static method ??? But the static method cannot call the instance method... Isn't it possible to call an instance method in the same class? For example: public class A {public static void main () {functiona (); // wouldn't an error be reported ?? Because main is static, and functiona is an instance method? } Public void functiona (){}}
Question added:
@ Thinkibm | you are right | but you can do this: | public static void main () {| new A (). functiona (); // No error will be reported. |}

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.