请解释我的逻辑为什么我得到以下代码的错误消息? [英] Please Explain me the logic Why I am get the Error Message for the Following Code ?

查看:68
本文介绍了请解释我的逻辑为什么我得到以下代码的错误消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

package com.contruct;

class Example{
	   //I did not define any constructor here
	   public void disp()
	   {
	      System.out.println("disp method of Example class");
	   }
//	   public static void main(String args[]){
	      Example obj2 = new Example();
//	      obj2.disp();
	   
	}

错误是

错误:在com.contruct.Example类中找不到主要方法,请将main方法定义为:

public static void main( String [] args)

或JavaFX应用程序类必须扩展javafx.application.Application



我理解,如果我删除评论,代码运行正常,但我想了解逻辑,为什么显示编译错误

Error is
Error: Main method not found in class com.contruct.Example, please define the main method as:
public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application

I understant ,if i remove comment ,code will run fine ,but I want to understand the logic ,Why Its Showing compilation Error

推荐答案

主要方法是任何java程序的起点。阅读更多: Java中的主要方法是什么? [ ^ ]
The main method is the start point of any java program. Read more: What is main method in Java ?[^]


这篇关于请解释我的逻辑为什么我得到以下代码的错误消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆