Java and Movies

本文通过三部电影《阿甘正传》、《神探》和《赤壁》来比喻Java的发展历程和技术特性。从Java的历史背景到其在不同领域的应用,再到开发工具NetBeans的重要性,展示了Java作为一门编程语言的独特魅力。

 

Today i go to Nanjing agriculture university to help Huang Shan with her tech talk. I prepare a new tech talk about Java. Of cource, there are some movies i find, which are the same with some features of Java.The fisrt move is Forrest Gump.The actor is Tom Hanks who i like very much.Gump has low intelligence, however he has his own advantage. In every stage, he can always seize the chance using his feature.That is the similar with Java history. Java's old name is oak, which was used to embedded system.However, internet promote Java developing and make Java new life.
The second movie is Mad Detective. The detective can find human's different characters.The man in the movie has seven characters. In fact, Java can delegate different meanings, too. You can say Java is a program lanaguage. You also can say Java is the develop platform, including JavaSE, JavaEE and JavaME. Of cource, Java is the brand. Sun adopts JAVA as his stock name.
The third movie is Three Kingdoms: Resurrection of the Dragon. The story is about famous hero Zhao Yun in China. He is the common soldier at first.However, he has many advantages which can make him become a General. So when a chance happens, he seizes it and let people know him. Netbeans which is excellent develop tool for Java is the similar. Netbeans has so many advantages and it need an opportunity, so Jolt which is the oscar in softare gives netbeans the chance: Netbeans gets Jolt award and Productivity Award in these two years. Whatever, Hope you will like and know Java and Netbeans through these movies.


       

 

以下为您提供几个Java基础案例: 1. **验证码生成案例**:该案例通过`Random`类生成指定长度的验证码,验证码包含数字、大写字母和小写字母。 ```java import java.util.Random; //验证码 public class Test2 { public static void main(String[] args) { System.out.println(createCode(20)); } public static String createCode(int n){ Random r=new Random(); String code=""; for (int i = 1; i <=n; i++) { int type=r.nextInt(3); switch (type){ case 0: code+=r.nextInt(10); break; case 1: char ch1=(char)(r.nextInt(26)+65); code+=ch1; break; case 2: char ch2=(char)(r.nextInt(26)+97); code+=ch2; break; } } return code; } } ``` 2. **电影信息遍历案例**:此案例创建了`Movie`对象并存储在`ArrayList`集合中,然后遍历集合输出每部电影的名称、得分和主演信息。 ```java import java.util.ArrayList; class Movie { private String name; private double score; private String actor; public Movie(String name, double score, String actor) { this.name = name; this.score = score; this.actor = actor; } public String getName() { return name; } public double getScore() { return score; } public String getActor() { return actor; } } public class ArrayListTest2 { public static void main(String[] args) { Movie m1 = new Movie("《肖申克的救赎》",9.7,"罗宾斯"); Movie m2 = new Movie("《霸王别姬》",9.6,"张国荣,张丰毅"); Movie m3 = new Movie("《阿甘正传》",9.5,"汤姆.汉克斯"); ArrayList<Movie> movies = new ArrayList<>(); movies.add(m1); movies.add(m2); movies.add(m3); for (int i = 0; i < movies.size(); i++) { Movie m = movies.get(i); System.out.println("电影名称: "+m.getName()); System.out.println("电影得分: "+m.getScore()); System.out.println("电影主演: "+m.getActor()); System.out.println("----------------------"); } } } ``` 3. **数组元素求和案例**:该案例使用`for`循环遍历数组,找出满足条件(个位和十位都不为7且为偶数)的元素并求和。 ```java public class arrayNumberAdd { public static void main(String[] args) { int[] arr = {68, 27, 95, 88, 171, 996, 51, 210}; System.out.println("满足条件的数组元素和为:" + addArray(arr)); } public static int addArray(int[] arr) { int sum = 0; //开始遍历 for (int i = 0; i < arr.length; i++) { int ge = arr[i] % 10; int shi = arr[i] / 10 % 10; if (ge != 7 && shi != 7 && arr[i] % 2 == 0) { sum += arr[i]; } } return sum; } } ``` 4. **最大公约数和最小公倍数案例**:该案例通过用户输入两个整数,计算并输出它们的最大公约数和最小公倍数。 ```java import java.util.Scanner; public class GCDAndLCM { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.println("请输入第一个正整数:"); int m = scan.nextInt(); System.out.println("请输入第二个正整数:"); int n = scan.nextInt(); //获取最大公约数 int min = (m <= n) ? m : n; for (int i = min; i >= 1; i--) { if (m % i == 0 && n % i == 0) { System.out.println("最大公约数为:" + i); break; } } //获取最小公倍数 int max = (m >= n) ? m : n; for (int i = max; i <= m * n; i++) { if (i % m == 0 && i % n == 0) { System.out.println("最小公倍数为:" + i); break; } } } } ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值