Created
November 19, 2015 02:32
-
-
Save hagun/47d377579d071acb4cde to your computer and use it in GitHub Desktop.
삼항연산자
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Db { | |
| public static void main(String[] args) { | |
| Object a = (true ? new Integer(1) : new Double(1.0)); | |
| System.out.println(a); | |
| if (a instanceof Integer) { | |
| System.out.println("Integer"); | |
| } else if (a instanceof Double) { | |
| System.out.println("Double"); | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Str { | |
| public static void main(String[] args) { | |
| Object a = (true ? new Integer(1) : new String("test")); | |
| System.out.println(a); | |
| if (a instanceof Integer) { | |
| System.out.println("Integer"); | |
| } else if (a instanceof String) { | |
| System.out.println("String"); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment