javaÖеĹؼü×Ö£¨transient£©
transientÕâ¸ö¹Ø¼ü×Ö²¢²»³£¼û£¬Ö÷ÒªÓ¦ÓÃÔÚjavaµÄÐòÁл¯·½Ãæ¡£ÕâÀïÎÒÔÙ¶à˵£¬×ªÒ»ÆªÀÏÍâµÄÎÄÕ£¬ºÜÉú¶¯£¬ÐÀÉͰÉ
Be Careful With Transient Data
Java's serialization provides an elegant, and easy to use mechanism for making an object's state persistent. While controlling object serialization, we might have a particular object data member that we do not want the serialization mechanism to save.
To turn off serialization on a certain field of an object, we tag that field of the class of our object with the Java's "transient" keyword. This, to low-level parts of the Java virtual machine, is an indication that the transient variable is not part of the persistent state of an object.
First, let's have some backgrounder code with Java's serialization.
Suppose we define a class as:
public class LoggingInfo implements java.io.Serializable
{
private Date loggingDate = new Date();
private String uid;
private transient String pwd;
LoggingInfo(String user, String password)
{
uid = user;
pwd = password;
}
public String toString()
{
String password=null;
if(pwd == null)
{
password = "NOT SET";
}
else
{
password = pwd;
}
return "logon info: \n " + "user: " + uid +
"\n
Ïà¹ØÎĵµ£º
½«ÒÔÏÂÄÚÈݸ´ÖÆEclipseÖÐÔËÐУ¬ËæÒâÊäÈëÒ»¸öÓû§Ãû£¬³ÌÐò»á×Ô¶¯¼ÆËã³ö×¢²áÂ룬¾ø¶ÔÄÜÓã¡£¡£¡
package sun;
import java.io.*;
public class MyEclipseGen {
private static f ......
¹Ø¼ü×Ö: javaÖÐjxlµ¼³öÊý¾Ýµ½excelµÄÀý×Ó
ÒªÍùxlsÎļþÀïÃæÐ´ÈëÊý¾ÝµÄʱºòÐèҪעÒâµÄÊǵÚһҪн¨Ò»¸öxlsÎļþ
OutputStream os=new FileOutputStream("c:\\excel2.xls" );
ÔÙ½¨ÍêÕâ¸öÎļþµÄʱºòÔÙ½¨Á¢¹¤×÷Îļþ
jxl.write.WritableWorkbook wwb = Workbook.createWorkbook(new File(os));
Èç¹ûÕâ¸öÎļþÒѾ´æÔÚ,ÄÇà ......
1.½Ó¿ÚµÄ¶¨Ò壺
interface ½Ó¿ÚÃû
{ ½Ó¿ÚÌ壻 }
×¢Ò⣺½Ó¿ÚÌåÖÐÖ»Äܰüº¬³£Á¿¶¨ÒåºÍ·½·¨¶¨ÒåÁ ......
½«×Ö´® String ת»»³ÉÊý×ÖÀàÐÍ
String ת int
1.) int i = Integer.parseInt([String]); »ò i = Integer.parseInt([String],[int radix]);
2.) int i = Integer.valueOf(my_str).intValue();
String ת Float
Float f = Integer.valueOf(my_str).floatValue();
String ת float
float f=new Float(my+str).floa ......