看一下java api
----------------------------------------------------------------------------------------
public void print(char[] s)
Prints an array of characters. The characters are converted into bytes
according to the platform's default character encoding, and these bytes are
written in exactly the manner of the write(int)
method.
Parameters:
s - The array of chars to be printed
Throws:
NullPointerException
- If s is null
----------------------------------------------------------------------------------------
println
public void println(char[] x)
Prints an array of characters and then terminate the line. This method
behaves as though it invokes print(char[])
and then println().
Parameters:
x - an array of chars to print.
----------------------------------------------------------------------------------------
一目了然,
println()不会抛出任何异常,即使是空的。
print()如果是空的,会抛出NullPointerException异常。
一定是你的代码哪里有问题,下面是我的代码,打印正常
import org.junit.Test;
public class My {
@Test
public void run() {
InstanceSet set = new InstanceSet(5);
System.out.println(set.getNode(2));
System.out.print(set.getNode(2));
}
public class Node {
}
public class InstanceSet {
private Node[] cycle;
public InstanceSet(int sum) {
cycle = new Node[sum];
for (int i = 0; i < sum; i++)
cycle[i] = new Node();
}
public Node getNode(int index) throws ArrayIndexOutOfBoundsException {
return cycle[index];
}
}
}
就这区别 似乎 --没其他区别
有Node类的代码吗?你的QQ是多少?我直接联系你。