package netconnection;/**
*
* @author Administrator
*/
public class NetConnection { /**
* @param args the command line arguments
*/
private final static int MAX_CONNECTION_NUM=10;
private static int connectionNum=0;
private NetConnection(){
connectionNum++;
connectionNum++;
connectionNum++;
}
public static NetConnection getNetConnection(){
if(connectionNum>=MAX_CONNECTION_NUM) {
return null;
}
else {
return new NetConnection();
}
}
public void release(){
connectionNum--;
}
public static void main(String[] args) {
// TODO code application logic
Netconnection NC=new Netconnection();
System.out.println("connectionNum"+NC.connectionNum);
}
}
错误就出现在最后一行程序的NC.connectionNum,不知道要改成什么哈?要怎么改,程序才能运行呢?
*
* @author Administrator
*/
public class NetConnection { /**
* @param args the command line arguments
*/
private final static int MAX_CONNECTION_NUM=10;
private static int connectionNum=0;
private NetConnection(){
connectionNum++;
connectionNum++;
connectionNum++;
}
public static NetConnection getNetConnection(){
if(connectionNum>=MAX_CONNECTION_NUM) {
return null;
}
else {
return new NetConnection();
}
}
public void release(){
connectionNum--;
}
public static void main(String[] args) {
// TODO code application logic
Netconnection NC=new Netconnection();
System.out.println("connectionNum"+NC.connectionNum);
}
}
错误就出现在最后一行程序的NC.connectionNum,不知道要改成什么哈?要怎么改,程序才能运行呢?
NetConnection NC=new NetConnection();
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package netconnection;/**
*
* @author Administrator
*/
public class NetConnection { /**
* @param args the command line arguments
*/
private final static int MAX_CONNECTION_NUM=10;
private static int connectionNum=0;
private NetConnection(){
connectionNum++;
connectionNum++;
connectionNum++;
}
public static NetConnection getNetConnection(){
if(connectionNum>=MAX_CONNECTION_NUM) {
return null;
}
else {
return new NetConnection();
}
}
public void release(){
connectionNum--;
}
public static void main(String[] args) {
// TODO code application logic
NetConnection NC=new NetConnection();
System.out.println("connectionNum"+NetConnection.connectionNum);
}
}
正确的代码!!!