Bài viết này tôi sẽ hướng dẫn một số cách để chuyển đổi kiểu dữ liệu Short thành kiểu dữ liệu String trong ngôn ngữ lập trình Java.
Mã nguồn - Source Code
/**
* @(#)ConvertShortToString.java
*
* ConvertShortToString application
*
* @author: BUI NGOC SOn
* @web: vnlives.net
* @version 1.00 2014/6/11
*/
public class ConvertShortToString {
public static void main(String[] args) {
//Declare a new Short object.
//Khai báo một đối tượng Short
Short sObj = new Short("1212");
//To convert Short to String use toString method of Short wrapper class
//Để chuyển đổi kiểu Short thành String sử dụng phương toString của lớp Short.
String strShortValue = sObj.toString();
System.out.println("Short converted to String: " + strShortValue);
}
}
* @(#)ConvertShortToString.java
*
* ConvertShortToString application
*
* @author: BUI NGOC SOn
* @web: vnlives.net
* @version 1.00 2014/6/11
*/
public class ConvertShortToString {
public static void main(String[] args) {
//Declare a new Short object.
//Khai báo một đối tượng Short
Short sObj = new Short("1212");
//To convert Short to String use toString method of Short wrapper class
//Để chuyển đổi kiểu Short thành String sử dụng phương toString của lớp Short.
String strShortValue = sObj.toString();
System.out.println("Short converted to String: " + strShortValue);
}
}
Kết quả - Result
No comments:
Post a Comment