Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

#Java 7:(削除) 53 (削除ここまで) 52 Bytes

Java 7:(削除) 53 (削除ここまで) 52 Bytes

int g(String _){return"google"==_?0/0:_.length();} 

Above code will throw ArithmeticException for division by zero and for any String other than google. Worth to note that == compares reference and won't work for String Objects.

Java 8 : 29 Bytes

#Java 8 : 29 Bytes (Based on suggestion given in below comment)

s->s=="google"?0/0:s.length()

#Java 7:(削除) 53 (削除ここまで) 52 Bytes

int g(String _){return"google"==_?0/0:_.length();} 

Above code will throw ArithmeticException for division by zero and for any String other than google. Worth to note that == compares reference and won't work for String Objects.

#Java 8 : 29 Bytes (Based on suggestion given in below comment)

s->s=="google"?0/0:s.length()

Java 7:(削除) 53 (削除ここまで) 52 Bytes

int g(String _){return"google"==_?0/0:_.length();} 

Above code will throw ArithmeticException for division by zero and for any String other than google. Worth to note that == compares reference and won't work for String Objects.

Java 8 : 29 Bytes

(Based on suggestion given in below comment)

s->s=="google"?0/0:s.length()
added 57 characters in body
Source Link

#Java 7:(削除) 53 (削除ここまで) 52 Bytes

int g(String _){return"google"==_?0/0:_.length();} 

Above code will throw ArithmeticException for division by zero and for any String other than google. Worth to note that == compares reference and won't work for String Objects.

#Java 8 : 29 Bytes (Based on suggestion given in below comment)

s->s=="google"?0/0:s.length()

#Java (削除) 53 (削除ここまで) 52 Bytes

int g(String _){return"google"==_?0/0:_.length();} 

Above code will throw ArithmeticException for division by zero and for any String other than google. Worth to note that == compares reference and won't work for String Objects.

#Java 7:(削除) 53 (削除ここまで) 52 Bytes

int g(String _){return"google"==_?0/0:_.length();} 

Above code will throw ArithmeticException for division by zero and for any String other than google. Worth to note that == compares reference and won't work for String Objects.

#Java 8 : 29 Bytes (Based on suggestion given in below comment)

s->s=="google"?0/0:s.length()
added 10 characters in body
Source Link

#Java 53(削除) 53 (削除ここまで) 52 Bytes

int g(String s_){return"google"==sreturn"google"==_?null0/0:s_.length();} 

Above code will throw very famous NullPointerExceptionArithmeticException for division by zero and for any String other than google. Worth to note that == compares reference and won't work for String Objects.

#Java 53 Bytes

int g(String s){return"google"==s?null:s.length();} 

Above code will throw very famous NullPointerException and for any String other than google. Worth to note that == compares reference and won't work for String Objects.

#Java (削除) 53 (削除ここまで) 52 Bytes

int g(String _){return"google"==_?0/0:_.length();} 

Above code will throw ArithmeticException for division by zero and for any String other than google. Worth to note that == compares reference and won't work for String Objects.

deleted 170 characters in body
Source Link
Loading
Source Link
Loading

AltStyle によって変換されたページ (->オリジナル) /