필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Java equals() selection

조회 수: 1 (최근 30일)
Lucky
Lucky 2022년 11월 9일
마감: Steven Lord 2022년 11월 9일
In Java, if I try to do.equals() on a null string, a null pointer error is issued. I'm wondering whether I can perform the following if I'm attempting to compare if a string is equal to a constant string:
MY CONSTANT STRING.equals(aStringVariable)
I'm sure it'll work, but is this simply extremely bad code?
This is a common Java idiom known colloquially as a Yoda condition. Personally, I prefer to handle the null situation directly, but the Yoda method is widely used, and any competent Java programmer should quickly grasp what is going on. How should I proceed?
  댓글 수: 1
Steven Lord
Steven Lord 2022년 11월 9일
This doesn't seem to be related to MATLAB. If it is, please reopen the question and explain the connection. If it's not you'll probably get a more informed answer if you ask on a Java forum instead of MATLAB Answers.

답변 (0개)

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by