作者chiang0514 (ethan0514)
看板java
标题[问题]请问线上JAVA编辑器为什麽这样的语法不行
时间Mon Nov 15 20:58:14 2021
请问线上 网页版的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://webptt.com/cn.aspx?n=bbs/java/M.1636981096.A.9F9.html
1F:推 lycantrope: class has to be "Main" only if the class is public 11/15 21:07
2F:推 LPH66: 你想像这些地方你的程式是放在 Main.java 里编译的就好 11/15 23:34
3F:→ crazybad: 你存档成 Ideone.java 就不会有问题了 11/23 11:45
4F:推 mureka: 基本习惯,一个物件一个档(inner class 不算),档名跟物件 01/07 23:01
5F:→ mureka: 名相同 01/07 23:01