我想编译这个:
public class DNSLookUp {
    public static void main(String[] args)   {
        InetAddress hostAddress;
        try  {
            hostAddress = InetAddress.getByName(args[0]);
            System.out.println (hostAddress.getHostAddress());
        }
        catch (UnknownHostException uhe)  {
            System.err.println("Unknown host: " + args[0]);
        }
    }
}
我使用了javac dns.java,但是我遇到了一堆错误:
dns.java:1: error: The public type DNSLookUp must be defined in its own file
    public class DNSLookUp {
                 ^^^^^^^^^
dns.java:3: error: InetAddress cannot be resolved to a type
    InetAddress hostAddress;
    ^^^^^^^^^^^
dns.java:6: error: InetAddress cannot be resolved
    hostAddress = InetAddress.getByName(args[0]);
                  ^^^^^^^^^^^
dns.java:9: error: UnknownHostException cannot be …我试图在一个应用程序中使用两个视图来提出用户的行星重量.在多次重写java之后,我终于让它工作了......主要是,但是在公共类Planets上它告诉我"公共类型行星必须在它自己的文件中定义." 我进入清单并为它做了一个活动,但这没有任何帮助.行星已经是我的一个xml文件的名称.如何将公共类型转换为自己的文件?
activity_main.xml中:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
    android:id="@+id/askwtTextView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="17dp"
    android:layout_marginTop="19dp"
    android:text="@string/askwt" />
<EditText
    android:id="@+id/inputwtEditText"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/askwtTextView"
    android:layout_below="@+id/askwtTextView"
    android:layout_marginTop="26dp"
    android:ems="10"
    android:inputType="numberDecimal" />
<Button
    android:id="@+id/enterButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/inputwtEditText"
    android:layout_below="@+id/inputwtEditText"
    android:layout_marginTop="38dp"
    android:onClick="buttonclick"
    android:text="@string/enter" />
</RelativeLayout>
Planets.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
    android:id="@+id/planetTextView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/planet" />
<TextView
    android:id="@+id/textViewform2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="" />
<RadioGroup
    android:id="@+id/radioGroup1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >
    <RadioButton
        android:id="@+id/mercuryRadio"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:checked="true"
        android:text="@string/mercury" />
    <RadioButton
        android:id="@+id/venusRadio"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/venus" /> …