每个源代码中有且仅有个public类  其中包含main函数  但有时这个public关键字可以省略   对吗    我运行后可以通过  请解释

解决方案 »

  1.   

    当然可以了,建议你看看 java 的权限访问 部分 知识!
    (public,private,protected,default)
      

  2.   

    哦,好吧,我错了。/*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */package javaapplication1;/**
     *
     * @author Administrator
     */
    class NewClass {
        static public void main(String[] args){
            System.out.println("dksaljfkasj");
        }}
      

  3.   

    当然可以省略public了,只要是在访问权限范围内就行
      

  4.   

    代码中可以有一个PUBLIC类,也可以没有PUBLIC类。
    如果有PUBLIC类,MAIN()方法必须要放到PUBLIC类中。
    定义成PUBLIC的类可以跨包使用,默认不写PUBLIC只能在包内使用。
      

  5.   

    不可以,默认的是default类型的亚