javaÖÐstringÓëÆäËûÀàÐÍÖ®¼äµÄ»¥Ïàת»»
1.½«Int,Float,Double,Longת»»ÎªString
String s = ""+i;
String s = String.valueOf(i);
String s = Integer.toString(i);
µÚÒ»ÖÖ·½·¨£ºs = ""+i; //»á²úÉúÁ½¸öString¶ÔÏó
µÚ¶þÖÖ·½·¨£ºs=String.valueOf(i); //Ö±½ÓʹÓÃStringÀàµÄ¾²Ì¬·½·¨£¬Ö»²úÉúÒ»¸ö¶ÔÏó
µÚÈýÖÖ·½·¨£ºÐ§ÂÊ×î¸ß£¿
2.½«Stringת»»ÎªInt,Float,Double,Long
int i = Integer.parseInt(s);
int i = Integer.valueOf(s).intValue();
µÚÒ»ÖÖ·½·¨£ºi=Integer.parseInt(s);//Ö±½ÓʹÓþ²Ì¬·½·¨£¬²»»á²úÉú¶àÓàµÄ¶ÔÏ󣬵«»áÅ׳öÒì³£
µÚ¶þÖÖ·½·¨£ºi=Integer.valueOf(s).intValue();//Integer.valueOf(s) Ï൱ÓÚ new Integer(Integer.parseInt(s))£¬Ò²»áÅ×Òì³££¬µ«»á¶à²úÉúÒ»¸ö¶ÔÏó
3.½«Dateת»»ÎªString
DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
String s = format.format(date);
4.½«Stringת»»ÎªDate
DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Date date = format.parse(s);
------------------------------------------------------------------------------------------------------------
public class TypeChange {
public TypeChange() {
}
//change the string type to the int type
public static int stringToInt(String intstr)
{
Integer integer;
integer = Integer.valueOf(intstr);
return integer.intValue();
}
//change int type to the string type
public static String intToString(int value)
{
Integer integer = new Integer(value);
return integer.toString();
}
//change the string type to the float type
public static float stringToFloat(String floatstr)
{
Float floatee;
floatee = Float.valueOf(floatstr);
return floatee.floatValue();
}
//change the float type to the string type
public
Ïà¹ØÎĵµ£º
×÷ΪJava³ÌÐòÔ±À´Ëµ£¬×îÍ´¿àµÄÊÂÇéĪ¹ýÓÚ¿ÉÒÔÑ¡ÔñµÄ·¶Î§Ì«¹ã£¬¿ÉÒÔ¶ÁµÄÊéÌ«¶à£¬ÍùÍùÈÝÒ×ÎÞËùÊÊ´Ó¡£¸ù¾ÝÎҵľÑ飬°´ÕÕѧϰµÄÏȺó˳Ðò£¬ÍƼö¸ø´ó¼Ò£¬ÌرðÊÇÄÇЩÏë²»¶ÏÌá¸ß×Ô¼º¼¼ÊõˮƽµÄJava³ÌÐòÔ±ÃÇ¡£
Ò»¡¢Java±à³ÌÈëÃÅÀà
¶ÔÓÚûÓÐJava±à³Ì¾ÑéµÄ³ÌÐòÔ±ÒªÈëÃÅ£¬Ëæ±ã¶ÁʲôÈëÃÅÊé¼®¶¼Ò»Ñù£¬Õâ¸ö½×¶ÎÐèÒªÄã¿ìËÙµÄÕÆÎÕJava ......
URLµÄopenConnection()·½·¨½«·µ»ØÒ»¸öURLConnection¶ÔÏ󣬸öÔÏó±íʾӦÓóÌÐòºÍ URL Ö®¼äµÄͨÐÅÁ´½Ó¡£³ÌÐò¿ÉÒÔͨ¹ýURLConnectionʵÀýÏò¸ÃURL·¢ËÍÇëÇ󡢶ÁÈ¡URLÒýÓõÄ×ÊÔ´¡£
ͨ³£´´½¨Ò»¸öºÍ URL µÄÁ¬½Ó£¬²¢·¢ËÍÇëÇ󡢶ÁÈ¡´Ë URL ÒýÓõÄ×ÊÔ´ÐèÒªÈçϼ¸¸ö²½Ö裺
£¨1£©Í¨¹ýµ÷ÓÃURL¶ÔÏóopenConnection()·½·¨À´´´½¨URLConnectio ......
------------------------------------------------------------------------------------------------
Õ⼸ÌìÖ÷ÒªÊÇ¿ñ¿´Ô´³ÌÐò£¬ÔÚÃÖ²¹ÁËһЩÒÔǰ֪ʶ¿Õ°×µÄͬʱ£¬Ò²Ñ§»áÁ˲»ÉÙеÄ֪ʶ£¨±ÈÈç NIO£©£¬»òÕß³ÆΪм¼Êõ°É¡£
Ï̳߳ؾÍÊÇÆäÖÐÖ®Ò»£¬Ò»Ìáµ½Ị̈߳¬ÎÒÃÇ»áÏëµ½ÒÔÇ°¡¶²Ù×÷ϵͳ¡·µÄÉú²úÕßÓëÏû·ÑÕߣ¬ÐźÅÁ¿£¬Í¬²½¿ØÖÆ ......
this
¶ÔÏó±¾Éí¡£public class ThisTest {
ThisTest tTest;
public ThisTest(){
tTest = this;
}
public void test(){
System.out.println(this);
}
public static void main(String arg[]){
new ThisTest().test();
}
}
³ÉÔ±·½·¨ÒýÓá£
³ÉÔ±±äÁ¿ÒýÓá£public class ThisTest {
String name ......
//ת×Ôhttp://pterodactyl.javaeye.com/blog/345892
stack ºÍ heep ¶¼ÊÇÄÚ´æµÄÒ»²¿·Ö
stack ¿Õ¼äС£¬ËٶȱȽϿ죬 ÓÃÀ´·Å¶ÔÏóµÄÒýÓÃ
heep ´ó£¬Ò»°ãËùÓд´½¨µÄ¶ÔÏ󶼷ÅÔÚÕâÀï¡£
Õ»(stack):ÊÇÒ»¸öÏȽøºó³öµÄÊý¾Ý½á¹¹,ͨ³£ÓÃÓÚ±£´æ·½·¨(º¯Êý)ÖеIJÎÊý,¾Ö²¿±äÁ¿.
ÔÚjavaÖÐ,ËùÓлù±¾ÀàÐͺÍÒýÓÃÀàÐͶ¼ÔÚÕ»Öд洢.Õ»ÖÐÊý¾ÝµÄÉ ......