Java中ASC码与字符互相转化


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));
}

/**
* 字符转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;
}

}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM