java 3
overload and override
overload 这和返回值没有关系
override 这个如果父亲的方法是私有的,那不是,是全新的方法
1.5 有新feature了
为了避免你写N多的overload方法,比如 一个参数不定的累加方法
可以这样写
public static int add(int x,int... args) {
int sum = 0;
return sum;
}
其实"int... args"是个 [数组] 拉 注意一定要放最后哦
然后:
public static int add(int x,int... args) {
int sum = x;
for(int i=0;i<args.length;i++){
sum+=args[i];
}
return sum;
}
当然,上面对数组的遍历方法,新加坡人不是怎么喜欢!!
要用什么叠代器的,
先不说叠代器,还是用一下1.5新feature
enhance for loop
for( type var : collection){...}
不要你的 length 了,懒得去拿了,
就用var 一个一个去戳你collection里的东西,戳到一个拿出一个,然后run{...}
速度快,听说叠代器还要快!
可以改成这样了:
public static int add(int x,int... args) {
int sum = x;
for(int arg : args){
sum+=arg;
}
return sum;
}
★★这里的取名 arg : args ,是一定要这样取,否则就滚!!别来编程了
然后再说一下 这里的collection 一定要实现 Iterable interface..
可以去SUN 网 看 什么language specification
search for
langspec-3.0
The Java Language Specification,Third Edition
分享到:
相关推荐
Algorithm-Machine-Learning-for-Beginner-by-Python3.zip,斯克莱恩、坦索流。,算法是为计算机程序高效、彻底地完成任务而创建的一组详细的准则。
资源分类:Python库 所属语言:Python 资源全名:for-beginner-piano-0.3.1.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
Hacking-Secret-Ciphers-with-Python-A-beginner-s-guide-to-cryptography-and-computer-programming-with-Python.pdf
This book is for anyone who wants to learn computer programming and knows absolutely nothing about it. If you are wondering whether this book is going to teach you how to create amazing applets or ...
introduce in english
in-one programming reference * Covers the recent release of the Java 2 Platform Standard Edition 5.0 and the new J2SE Development Kit 5.0 * Starts with beginner topics including getting started ...
以pygame 游戏模块,来学习Python 基础,每章一个游戏。让python基础学得牢,学得有意思!
DSP for Embedded and Real-Time Systems is the reference for both the beginner and experienced, covering most aspects of using today’s DSP techniques and technologies for designing and implementing an...
Fully updated to cover Java Platform, Standard Edition 7 (Java SE 7), Java: A Beginner's Guide, Fifth Edition starts with the basics, such as how to compile and run a Java program, and then discusses...
Java初学者编程 书
Java Programming 24-Hour Trainer, 2nd Edition is your complete beginner's guide to the Java programming language, with easy-to-follow lessons and supplemental exercises that help you get up and ...
python_for_absolute_beginner-源码.rar
Pentaho 8 Reporting for Java Developers 英文azw3 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
rails-beginner-s-guide是Rails 指导手册,帮组学习了解rails开发
Beginner-CPP-Programming-From-Beginner-to-Beyond
Java Programming for the Absolute Beginner.pdf
神奇的perl-最佳PERL入门读物 非常好的入门资料
学习使用Java和Selenium进行自动化测试 课程链接: : 您迈向出色的自动化测试仪的... Mockito- https: //courses.in28minutes.com/p/mockito-for-beginner-in-5-steps 安装工具 安装视频: https : //www.youtube.co
Java入门指南 赫伯特·希尔德(Herbert Schildt)的书
ARM Cortex-M 处理器家族介绍和比较,非常经典!!!非常经典!!!非常经典!!!对于刚刚入门的来说,非常值得一看,主要讲解了 Cortex-M 系列处理器的系统框架与编程框架。