Read notes for core java: Objects and classes
2010-04-28 14:53
543 查看
Due the data types in java are all referrence type,we must follows as bellows:
1. not to write accessor methods that return referrences to mutable objects.
2. always use clone whenever you need to return a copy of a mutable data field.
example:
class Employee
{
. . .
public Date getHireDay()
{
return (Date) hireDay.clone();
}
. . .
}
Method parameters
The method paramters in java is always passed by value. Object references are passed by value.
1. A method cannot modify a parameter of primitive type( that is, numbers or boolean values);
2. A method can change the state of an object parameter;
3. A method cannot make an object parameter refer to a new object.
Private keyword
Variables must explicitly be marked private or they will default to being package visible.
The Class Path
The javac complier always looks for files in the current diretory, but the java virtual machine launcher only looks into the current directory if the "." directory is on the class path. If you have no class path set, this is not a problem--the default class path consists of the "." directory. But if you hava set the class path and forgot to include the "." directory, your programs will compile without error, but they won't run.
相关文章推荐
- Java 基础 —— Objects and Classes
- Reloading Java Classes 101: Objects, Classes and ClassLoaders Translation
- studio混淆apk打包错误:app:transformClassesAndResourcesWithProguardForRelease'. > java.ioe异常
- Java学习笔记(9)Objects and Classes
- Java Reflection Tutorial for Classes, Methods, Fields, Constructors, Annotations and much more
- Core Java Volume I — 5.1. Classes, Superclasses, and Subclasses
- Generate Java objects for FpML using JAXB and Maven: The Easy Way!
- How do I download and install Java for my Linux computer?
- 混淆代码问题之没有jar包的解析Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRel
- Chapter 2 Classes and Objects
- Java for Web学习笔记(二八):JSTL(4)Core Tag(下)
- Java™ Development on PDAs: Building Applications for PocketPC and Palm Devices
- Core Security Patterns : Best Practices and Strategies for J2EE(TM), Web Services, and Identity Mana
- java cannot find the tag library descriptor for "http://java.sun.com/jsp/jstl/core"
- Units Problem: How to read text size as custom attr from xml and set it to TextView in java code
- out/target/common/obj/JAVA_LIBRARIES/core-libart_intermediates/with-local/classes.dex] Error 41
- Java Methods for Financial Engineering: Applications in Finance and Investment
- Regular Expression Pocket Reference: Regular Expressions for Perl, Ruby, PHP, Python, C, Java and .N
- (Core-JAVA) HashMap, HashTable and HashSet