4.1 import java.util.Scanner; public class Welcome { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter the length from the center to a vertex:"); double r = input.nextDouble(); double s = 2…
链式编程 每次调用方法后,返回的是一个对象 /* * 链式编程 * 每次调用方法后,返回的是一个对象 */ class Student { public void study() { System.out.println("good good study, day day up!"); } } class StudentDemo { public Student getStudent() { return new Student(); } } public class InnerCla…
答案为本人求解,如有错误,还望海涵.如有雷同,纯属巧合. 7.1 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter the number of students: "); int num = input.nextInt(); int sc…
答案为本人自己求解,若有错误,还望海涵并及时告知.如有雷同,纯属巧合. 2.1 import java.util.Scanner; public class Welcome { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter a degree in Celsius:"); double celsius = input.next…
例9.1一个文件复制应用程序,将某个文件的内容全部复制到另一个文件. import java.io.*; public class Example9_1 { public static void main(String arg[]) { File inputFile = new File("file1.txt"); File outputFile = new File("file2.txt"); int ch; try { FileReader in = new F…
例7.1小应用程序用6种字型显示字符串,显示内容说明本身的字型. import java.applet.*; import java.awt.*; public class Example7_1 extends Applet { Font f1 = new Font("Helvetica", Font.PLAIN, 18); Font f2 = new Font("Helvetica", Font.BOLD, 10); Font f3 = new Font(&quo…