programing

지원되지 않거나 구현되지 않은 작업에 대해 Java에서 발생하는 표준 예외는 무엇입니까?

prostudy 2022. 8. 24. 23:41
반응형

지원되지 않거나 구현되지 않은 작업에 대해 Java에서 발생하는 표준 예외는 무엇입니까?

특히, 표준이 있나요?Exception서브클래스가 사용되는가?

java.displaces를 클릭합니다.지원되지 않는 조작예외.

요청된 작업이 지원되지 않음을 나타내기 위해 느려집니다.

지정한 두 가지 경우를 구분합니다.

  • 요청된 작업이 지원되지 않으며 앞으로도 지원되지 않을 것임을 나타내려면 를 슬로우합니다.

  • 요청된 작업이 아직 구현되지 않았음을 나타내려면 다음 중 하나를 선택합니다.

    1. commons-lang2에서 사용 가능하며 버전 3.2에서 commons-lang3에 다시 추가된 apache commons-lang에서를 사용합니다.

    2. 독자적인 실장소NotImplementedException.

    3. "Not implemented, 아직 구현되지 않았습니다"와 같은 메시지가 포함된 메시지를 던집니다.

NetBeans 에 새로운(아직 실장되어 있지 않은) 함수를 작성하면, 다음의 스테이트먼트를 가지는 메서드 본문이 생성됩니다.

throw new java.lang.UnsupportedOperationException("Not supported yet.");

따라서 Unsupported Operation을 사용할 것을 권장합니다.예외입니다.

보다 세밀하고 상세한 설명을 원하시면NotImplementedException에서

경고:버전 2.6 이전 및 버전 3.2 이후에만 사용할 수 있습니다.

이하Calculator샘플 클래스는 차이를 보여줍니다.

public class Calculator() {

 int add(int a , int b){
    return a+b;
  }

  int dived(int a , int b){
        if ( b == 0 ) {
           throw new UnsupportedOperationException("I can not dived by zero, 
                         not now not for the rest of my life!")
        }else{
          return a/b;
       }
   }

   int multiple(int a , int b){
      //NotImplementedException from apache or some custom excpetion
      throw new NotImplementedException("Will be implement in release 3.5");
   } 
}

언급URL : https://stackoverflow.com/questions/829136/what-is-the-standard-exception-to-throw-in-java-for-not-supported-implemented-op

반응형