开发者

Java - error: incompatible types: Long cannot be converted to String [closed]

Closed. This question is not reproducible or was caused by typos. It is开发者_如何学Go not currently accepting answers.

This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.

Closed 10 hours ago.

Improve this question

When I run the below code, I am getting ./Solution.java:13: error: incompatible types: Long cannot be converted to String error. I am not able to understand why.

public class Solution {
    public Long solve(Long A, int B) {
        String binaryStr = "";

        while(true) {
            if(A > 6) {
                binaryStr = String.valueOf((A % 2)) + binaryStr;
            } else {
                binaryStr = "0" + binaryStr;
            }
            
            A = Math.floor(Integer.parseInt(A) / 2);
            if(A == 0) {
                break;
            }
        }
        return binaryStr;
    } 
}

Somebody help me fix this problem.

Thanks in advance.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜