View Full Version : แปลง string เป็น integerใน JAVA
ใช้คำสั่งอะไรครับ คือมีปัญหาในการเขียนโปรแกรมเพราะถ้า ไม่แปลงค่ามาเป็นตัวเลขจะต้อง check เงื่อนไข if ยาวเลย ช่วยหน่อยนะครับ
[Edited by admin on 01-30-2003 at 10:28 AM GMT]
asylu3
30-01-2003, 05:26 PM
ลองดูโค้ดนี้ดูนะครับ คิดว่าคงพอได้ idea
String strNum = "123";
int intNum = Integer.parseInt(strNum);
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)
}
}
labyrinth
22-12-2004, 06:43 PM
กลับกันอะ
String str = Integer.toString(123);
class Input{
public String getInput() {
char buf = '
ทำไรกันยืดยาวครับแค่แปลงเลขเป็นสตริง
String s = 1 + "";
kingmot
08-11-2006, 09:34 AM
Converting int to string
String myString = Integer.toString(my int value)
or
String str = "" + i
ที่มา : http://www.narisa.com/forums/index.php?showtopic=11724
Powered by vBulletin® Version 4.2.5 Copyright © 2026 vBulletin Solutions Inc. All rights reserved.