♣ Tech & Biz Salon/Tech

java String equals() 사용시 Tip

TasteGod 2012. 3. 22. 10:41

1. 일반적인 코딩방식
if( pushHead.getServerType().equals("APNS") )
{ ...

pushHead.getServerType() 값이 Null 일때 Exception 발생

2. Tip
if( "APNS".equals( pushHead.getServerType() ) )
{ ...

pushHead.getServerType() 값이 Null 일때 Exception 발생하지 않음.