package com.ljq.test;
/**
* Java中ASC码与字符互相转化
*
* @author jiqinlin
*
*/
public class ASCTest {
private static int ascNum;
private static char strChar;
public static void main(String[] args) {
System.out.println(getAsc("a"));
System.out.println(backchar(98));
System.out.println((int)'A');
System.out.println((char)65); }
/**
* 字符转ASC
*
* @param st
* @return
*/
public static int getAsc(String st) {
byte[] gc = st.getBytes();
ascNum = (int) gc[0];
return ascNum;
}
/**
* ASC转字符
*
* @param backnum
* @return
*/
public static char backchar(int backnum) {
strChar = (char) backnum;
return strChar;
}
}
分享到:
2013-05-17 20:54
浏览 11018
评论
1 楼
pikeini
2016-07-11