ใช้คำสั่งอะไรครับ คือมีปัญหาในการเขียนโปรแกรมเพราะถ้า ไม่แปลงค่ามาเป็นตัวเลขจะต้อง check เงื่อนไข if ยาวเลย ช่วยหน่อยนะครับ
[Edited by admin on 01-30-2003 at 10:28 AM GMT]
ใช้คำสั่งอะไรครับ คือมีปัญหาในการเขียนโปรแกรมเพราะถ้า ไม่แปลงค่ามาเป็นตัวเลขจะต้อง check เงื่อนไข if ยาวเลย ช่วยหน่อยนะครับ
[Edited by admin on 01-30-2003 at 10:28 AM GMT]
ลองดูโค้ดนี้ดูนะครับ คิดว่าคงพอได้ idea
[src]
String strNum = "123";
int intNum = Integer.parseInt(strNum); [/src]
class Test1 {
public static void main(int args[]){
int n = (args[0]);
System.out.println(n);
}
}
Class Test2 {
public static void main(String args[]){
int n = Integer.parseInt(args[0]);
System.out.println(n)
}
}
กลับกันอะ
Code:String str = Integer.toString(123);
http://img98.imageshack.us/img98/731/ubd7518fj8.png
XSI - Behavior Programmer
Boardgame Thailand Fanclub
Ball Juggling~
class Input{
public String getInput() {
char buf = '
ทำไรกันยืดยาวครับแค่แปลงเลขเป็นสตริง
String s = 1 + "";
Converting int to string
String myString = Integer.toString(my int value)
or
String str = "" + i
ที่มา : http://www.narisa.com/forums/index.php?showtopic=11724
Actions : (View-Readers)
There are no names to display.