LLLLLLapra 2021-11-09 19:57 采纳率: 100%
浏览 31
已结题

求个专家看看,这里的return true 输出的到底是个什么,为什么最后输出的是个2,这个return的作用是什么?

public boolean findWay(int[][] map,int i,int j) {
    if(map[6][5] == 2) {
        return true;
    } else {
        if(map[i][j] == 0) {
            map[i][j] = 2;
            if(findWay(map,i + 1,j)) {
                return true;
            } else if(findWay(map,i,j + 1)) {
                return true;
            } else if(findWay(map,i - 1,j)) {
                return true;
            } else if (findWay(map,i,j - 1)) {
                return true;
            } else {
                map[i][j] = 3;
                return false;
            }
        }
        else {
            return false;
  • 写回答

1条回答 默认 最新

  • CSDN专家-sinJack 2021-11-09 20:00
    关注

    要看调用的地方,调用的地方,判断这个方法的返回真假来做业务处理。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
    1人已打赏

报告相同问题?

问题事件

  • 系统已结题 11月17日
  • 已采纳回答 11月9日
  • 创建了问题 11月9日