chapter3n1.java
来自「JAVA源代码程序aashjkjhkjhkjhjkhkj」· Java 代码 · 共 63 行
JAVA
63 行
/** * * demonstration of the manipulation of "Person" objects * * Written by: Roger Garside * * First Written: 12/June/96 * Last Rewritten: 2/Oct/96 * */import java.lancs.* ;public class Chapter3n1 { /** * * main * */ public static void main(String[] args) { // step 1 - declare two "Person" variables Person person1 = new Person() ; Person person2 = new Person() ; // step 2 - set the attributes of "person1" person1.setForename("John") ; person1.setSurname("Smith") ; person1.setAge(24) ; // step 3 - set the attributes of "person2" person2.setForename("Peter") ; person2.setSurname("Wright") ; person2.setAge(19) ; // step 4 - display the attributes of "person2" System.out.print("the second person is ") ; System.out.print(person2.getForename()) ; System.out.print(" ") ; System.out.print(person2.getSurname()) ; System.out.print(" (") ; System.out.print(person2.getAge()) ; System.out.println(")") ; // step 5 - leave a blank line System.out.println() ; // step 6 - display the attributes of "person1" System.out.print("the first person is ") ; System.out.print(person1.getForename()) ; System.out.print(" ") ; System.out.print(person1.getSurname()) ; System.out.print(" (") ; System.out.print(person1.getAge()) ; System.out.println(")") ; } // end of method main } // end of class Chapter3n1
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?