Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


How to determine whether a object is vector type?

Posted on 2003-02-27
Medium Priority
Last Modified: 2010-03-31
I would like to have a variable type(the only one I can think of is Object) that able to hold Vector and String.


   Object a = null;
   a = new Vector();
   a = new String("");

   If a is vector then do something else do nothing;
   How to determine if a is vector or not. There is not such method a.isVector().

Please advise.
Question by:realman1
  • 2
LVL 92

Accepted Solution

objects earned 600 total points
ID: 8039596
if (a instanceof Vector)
else if (a instanceof String)

Author Comment

ID: 8039723
Hello, Object. It has been quite long time I didn't visit this forum. Nice to hear from you again. :)

Thank you for your fast response and accurate answer.
LVL 92

Expert Comment

ID: 8039735
Happy I could help :-)

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month14 days, 7 hours left to enroll

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question