wwhui
发贴: 10
积分: 0
|
于 2006-09-18 21:42
我自己写了一个方法用于动态接收数字. 编译没有错误,但是运行不了.请帮忙看一下.不声感激!! //method; public static int transform(int j)throws Exception {ByteArrayOutputStream bb=new ByteArrayOutputStream(); while(bb.size()!=j) bb.write(System.in.read()); int p=Integer.parseInt(bb.toString()); return p; } 完整程序如下: import java.io.*; import java.util.*; public class tomorrowdate {public static void main(String args[])throws Exception {int m=0,n=0,k=0; System.out.println("输入年(4):"); m=transform(4); System.out.println("输入月(2):"); n=transform(2); System.out.println("输入日(2):"); k=transform(2); System.out.println(m); System.out.println(n); System.out.println(k); } // public static int transform(int j)throws Exception {ByteArrayOutputStream bb=new ByteArrayOutputStream(); while(bb.size()!=j) bb.write(System.in.read()); int p=Integer.parseInt(bb.toString()); return p; } // }
bluecrystal edited on 2006-09-18 23:11
|