标题:[求助]这个问题如何解决 ,关于NullPointerException
只看楼主
patricknb
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2007-9-21
 问题点数:0 回复次数:1 
[求助]这个问题如何解决 ,关于NullPointerException
public class CoordinateMaker
{
public static void createCoordinate(Coordinate newCoordinate, int rows, int columns)
{
newCoordinate = new Coordinate(rows, columns);
}

public static void main(String[] args)
{
Coordinate coord = null;
createCoordinate(coord, 3, 7);
System.out.println("coord has the value (" + coord.getRow() + ", " + coord.getCol() + ")");
}
}
2007-10-21 07:34
sayadiva
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2007-10-21
得分:0 
以下是引用patricknb在2007-10-21 7:34:06的发言:
public class CoordinateMaker
{
public static Coordinate createCoordinate(Coordinate newCoordinate, int rows, int columns)
{
newCoordinate = new Coordinate(rows, columns);
return newCoordinate;
}

public static void main(String[] args)
{
Coordinate coord = null;
coord = createCoordinate(coord, 3, 7);
System.out.println("coord has the value (" + coord.getRow() + ", " + coord.getCol() + ")");
}
}


2007-10-21 08:15



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-179442-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.351873 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved