看板 java 關於我們 聯絡資訊
請問線上 網頁版的JAVA編輯器 在:https://www.tutorialspoint.com/compile_java_online.php 在:https://www.jdoodle.com/online-java-compiler/ 在:https://ideone.com/ /* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Test{ int a; } class Ideone { public static void main (String[] args) throws java.lang.Exception { Test test = new Test(); } } Main.java:9: error: class Test is public, should be declared in a file named Test.java public class Test{ ^ 1 error 宣告類別怎麼都不能成功編譯成功呢? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 123.192.61.82 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/java/M.1636981096.A.9F9.html
lycantrope: class has to be "Main" only if the class is public 11/15 21:07
LPH66: 你想像這些地方你的程式是放在 Main.java 裡編譯的就好 11/15 23:34
crazybad: 你存檔成 Ideone.java 就不會有問題了 11/23 11:45
mureka: 基本習慣,一個物件一個檔(inner class 不算),檔名跟物件 01/07 23:01
mureka: 名相同 01/07 23:01