Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Just a simple doubt  RSS feed

 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,
Can you please tell me if we can do this:
From my first java class,I create an object reference to the second class and call a method of that class eg.

I know under normal circumstances this would throw a null pointer exception as I need to do something like this;

But is it possible to use Reflection or some other technique to accomplish the first thing???
Thanks
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you already tried yourself the first snippet and it threw NullPointerException. The only difference with using reflection it that it will work with a null reference if the method is static. If not static - you will get the exception again.
 
Jas Oberai
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Buddy,
But the method is not static...so as you say there's probably no other way to do such thing.
Thanks
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!