服务热线:13616026886

技术文档 欢迎使用技术文档,我们为你提供从新手到专业开发者的所有资源,你也可以通过它日益精进

位置:首页 > 技术文档 > JAVA > 新手入门 > 基础入门 > 查看文档

java控制台输入,输出!


  /* * created on 2005-4-5
* * todo to change the template for this generated file go to
* window - preferences - java - code style - code templates
*/

import java.io.bufferedreader;
import java.io.ioexception;
import java.io.inputstreamreader;

/**
* @author zhangql
*
* todo to change the template for this generated type comment go to
* window - preferences - java - code style - code templates
*/
public class enterconsole
{
public static void main(string[] args) throws ioexception
{
enterconsole enterconsole = new enterconsole();
enterconsole.printconsolechar();
}
/**
* 从控制对接收一行字符串,然后输出到控制台
* @throws ioexception
*/
public void printconsoleline() throws ioexception
{
bufferedreader br = new bufferedreader(new inputstreamreader(system.in));
string str = null;
system.out.println("enter your value:");
str = br.readline();
system.out.println("your value is :"+str);
}
/**
* 从控制台接收一个字符
* 然后打印到控制台上
* @throws ioexception
*/
public void printconsolechar() throws ioexception
{
system.out.print("enter a char:");
char i = (char) system.in.read();
system.out.println("your char is :"+i);
}
}

扫描关注微信公众号