-
Enhancement
-
Resolution: Won't Fix
-
P4
-
None
-
1.1, 6
-
None
-
generic, x86, sparc
-
generic, solaris_2.5.1, windows_nt
Name: mc57594 Date: 02/13/97
I often find myself writing code that looks like this:
void blah (Object x)
{
if (x instanceof ClassOne)
{
ClassOne x1 = (ClassOne) x;
...;
}
else if (x instanceof ClassTwo)
{
ClassTwo x2 = (ClassTwo) x;
...;
}
...;
}
It'd sure be nice if Java offered a typecase-like statement,
especially since it already has it for exceptions! The above could
look something like this:
void blah (Object x)
{
typeswitch (x)
{
case ClassOne x1:
{
...;
break;
}
case ClassTwo x2:
{
...;
break;
}
...;
}
}
company - Electric Communities , email - ###@###.###
======================================================================
- duplicates
-
JDK-6204730 Adding typeswitch to Java
-
- Closed
-
-
JDK-4034117 Switch statements on classes
-
- Closed
-
- relates to
-
JDK-5012262 Using Strings and Objects in Switch case statements.
-
- Closed
-