1.熟悉本机的jdk安装目录及注意环境变量的设置,如果未安装自行下载安装jdk7并安装(注意环境变量的设置)。
2.在记事本中编写一个简单的Java应用程序,该程序在命令行窗口输出两行文字:“我很高兴学习Java”和“We are students”。
编译器怎样提示语句丢失分号的错误?
编译器怎样提示将System写成system这一错误?
编译器怎样提示将String写成string这一错误?
3.在一个源文件中编写4个类Hello、A、B和C,主方法包含在类Hello中,类A、B、C中各包含一个静态和非静态方法,在类Hello的主方法中分别调用类A、B、C中的方法。
在一个源文件写多个类需要注意什么?
编译.java文件时会根据public修饰的类生成 .class文件。类的多少没有限制,不过一个java源文件最多只能有一个public 修饰的 class。
该题中最终会产生几个class文件?
四个
在一个类中如何调用其他类中的方法(非静态方法和静态方法)?
非静态方法得先创建对象,通过对象.方法名调用。静态方法可直接通过类名.方法调用。
//源码
2.在记事本中编写一个简单的Java应用程序,该程序在命令行窗口输出两行文字:“我很高兴学习Java”和“We are students”。
编译器怎样提示丢失大括号的错误?
编译器怎样提示语句丢失分号的错误?
编译器怎样提示将System写成system这一错误?
编译器怎样提示将String写成string这一错误?
3.在一个源文件中编写4个类Hello、A、B和C,主方法包含在类Hello中,类A、B、C中各包含一个静态和非静态方法,在类Hello的主方法中分别调用类A、B、C中的方法。
在一个源文件写多个类需要注意什么?
编译.java文件时会根据public修饰的类生成 .class文件。类的多少没有限制,不过一个java源文件最多只能有一个public 修饰的 class。
该题中最终会产生几个class文件?
四个
在一个类中如何调用其他类中的方法(非静态方法和静态方法)?
非静态方法得先创建对象,通过对象.方法名调用。静态方法可直接通过类名.方法调用。
//源码
package com.majing;
public class HelloABC {
public static void main(String[] args) {
// TODO Auto-generated method stub
//A的非静态方法--------------------------
A a = new A("I am");
System.out.println(a.charAt(3));
//A的静态方法
System.out.println(A.atoi("123456"));
//B的非静态方法--------------------------
B b = new B(20);
System.out.println(b.getB());
//B的静态方法
System.out.println(B.itoa());
//C的非静态方法
C c = new C(20.12f);
System.out.println(c.getC());
//C的静态方法
System.out.println(C.atof("12.125"));
}
}
class A{
static public String _a;
public A(String a){
this._a = a;
}
public char charAt(int index){
return _a.charAt(index);
}
public static int atoi(String b){
return Integer.parseInt(b);
}
}
class B{
public static int _b;
public B(int b){
this._b = b;
}
public int getB(){
return this._b;
}
public static String itoa(){
return String.valueOf(_b);
}
}
class C{
public float _c;
public C(float c){
this._c = c;
}
public float getC(){
return this._c;
}
public static float atof(String a){
return Float.parseFloat(a);
}
}
本文探讨了在Java编程中,当编译器提示丢失大括号错误时,如何理解和解决这类问题。通过深入理解大括号在控制流程语句中的作用,可以有效地避免和修复此类错误。
242

被折叠的 条评论
为什么被折叠?



