¾È±Ô °øºÎ¹æ

Android > Çüº¯È¯ - ¾Èµå·ÎÀ̵å Çüº¯È¯ ¿¹Á¦

µî·ÏÀÏ : 2017-07-05 11:04 Á¶È¸¼ö : 53,425

1. stringÀ» int·Î , int¸¦ stringÀ¸·Î º¯È¯.
Integer.parsInt(string º¯¼ö)´Â ¹®ÀÚ¸¦ ¼ýÀÚÇüÀ¸·Î ¹Ù²Ù¾î ÁÝ´Ï´Ù.
Integer.toString(int º¯¼ö) ´Â ¼ýÀÚ¸¦ ¹®ÀÚÇüÀ¸·Î ¹Ù²Ù¾î ÁÝ´Ï´Ù.

2. Boolean Çü º¯È¯ ¿¹Á¦
String strBool = "true";
Boolean boolObj = Boolean.valueOf(strBool);  //Boolean ÇüÀ¸·Î º¯È¯
Boolean bool = boolObj.booleanValue(); //true °ª Ãâ·Â
Boolean.getBoolean(strBool); //true °ª Ãâ·Â

3. Float Çü º¯È¯ ¿¹Á¦
String strNum = "2005.09";
float floatNum = Float.parseFloat(strNum); // ¹®ÀÚÇü -> Float Çü º¯È¯
int intNum = (int) Float.parseFloat(strNum); // ¹®ÀÚÇü -> Float Çü º¯È¯ ÈÄ Interger Çü º¯È¯ (Ãâ·Â:2005)


4. String Çü char[] Çü º¯È¯ ¿¹Á¦
String Ŭ·¡½º¿¡´Â ¹®ÀÚ¿­À» char ¹è¿­·Î º¯È¯ÇØÁÖ´Â ÇÔ¼ö°¡ ÀÖ½À´Ï´Ù.
toCharArray() ´Â char ¹è¿­ÀÌ ÀÖ´Â °÷ÀÇ ¸Þ¸ð¸® ÁÖ¼Ò¸¦ ¸®ÅÏÇÕ´Ï´Ù.
ÀÌ·¸°Ô char ¹è¿­ÀÎ µ¥ÀÌÅ͸¦ String À¸·Î º¯°æÇϱâ À§ÇØ Character Ŭ·¡½º¸¦ »ç¿ëÇÏ¿´½À´Ï´Ù.
char ¹è¿­ÀÇ ¿ä¼Ò°ª Çϳª¾¿ ²¨³»¼­ Character.toString() À» ÀÌ¿ëÇØ String À¸·Î ¹Ù²ÛÈÄ Çϳª¾¿ ÇÕÄ¡´Â °ÍÀÌÁÒ.

String str = "Çѱ۵¥ÀÌÅÍ º¯È¯Çϱâ";
char[] chr = str.toCharArray();
String change = "";

//1. Çϳª¾¿ ´õÇÏ´Â ¹æ¹ý
for (int i = 0; i < chr.length; i++) {
    change += Character.toString(chr[i]);
}

//2. String Ŭ·¡½º ÀÌ¿ë ÇÕÄ¡´Â ¹æ¹ý
change = new String(chr, 0, chr.length);

System.out.println(change);

5. long Çü -> String Çü º¯È¯ ¿¹Á¦
long i = 11211212.21212;
String str = Long.toString(i);


6. String Çü -> double Çü º¯È¯ ¿¹Á¦
double d = Double.valueOf(str).doubleValue();

long l = Long.parseLong(str);


7. String Çü -> float Çü º¯È¯ ¿¹Á¦
float f = Float.valueOf(str).floatValue();


8. decimal Çü -> binary Çü º¯È¯ ¿¹Á¦
int i = 42;
String binstr = Integer.toBinaryString(i);


9. decimal Çü -> hexadecimal Çü º¯È¯ ¿¹Á¦
int i = 42;
String hexstr = Integer.toString(i, 16);

10. hexadecimal (String) Çü -> integer Çü º¯È¯ ¿¹Á¦
int i = Integer.valueOf("B8DA3", 16).intValue();

¶Ç´Â

int i = Integer.parseInt("B8DA3", 16);    


11. ASCII CODE -> String Çü º¯È¯ ¿¹Á¦
int i = 64;
String aChar = new Character((char)i).toString();

12. integer Çü -> ASCII code (byte) º¯È¯ ¿¹Á¦
char c = 'A';
int i = (int) c; // i will have the value 65 decimal

13. Double Çü -> String Çü º¯È¯ ¿¹Á¦
double i = 1121.21212;
String str = Double.toString(i);

14. ArrayList¸¦ ¹è¿­ array·Î º¯È¯Çϱâ

		ArrayList tmpGroupList = new ArrayList();
		tmpGroupList.add("A");
		tmpGroupList.add("B");
		tmpGroupList.add("C");
		tmpGroupList.add("D");

		String[] groupList = new String[tmpGroupList.size()]; 
		tmpGroupList.toArray(groupList);

		for (String group : groupList)
		{
			System.out.println(group);
		}

		String[] groupList2 = new String[tmpGroupList.size()];
		Object[] ar = tmpGroupList.toArray();

		for (int idx=0; idx<groupList2.length; idx++)
			groupList2[idx] = (String) ar[idx];

		for (String group2 : groupList2)
		{
			System.out.println(group2);
		}

 
¡Ø Ȥ½Ã µµ¿òÀÌ µÇ¼Ì´Ù¸é ´ñ±Û¿¡ ÇѸ¶µð ³²°ÜÁÖ¼¼¿ä!
ÀÛ¼ºÀÚ   ºñ¹Ð¹øÈ£
ÀÚµ¿±Û ¹æÁö     (ÀÚµ¿±Û ¹æÁö ±â´ÉÀÔ´Ï´Ù.)
³»¿ë   ´ñ±Û´Þ±â 
À̸ÞÀÏ ¹®ÀÇ : cak0280@nate.com  
Copyright 2000 By ENTERSOFT.KR All Rights Reserved.