Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Pro JSP
|
Pro JSP Advanced JSP coding questions. Beginning questions will be redirected to the Beginning JSP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro JSP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 10th, 2006, 05:36 PM
Authorized User
 
Join Date: Oct 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default Required method?

Is it possible to write a class that, when instantiated by another class, requires the call of a certain method, or else will not compile?

For example:

I have two classes: A & B.

I want to write B such that when A instantiates B, it must call a certain method in B from somewhere within A. If that certain method is not called, I want to keep the class from compiling.

Is this possible?

 
Old May 18th, 2006, 11:39 AM
Authorized User
 
Join Date: Oct 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ttt

 
Old July 1st, 2006, 07:39 PM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 198
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can't do that. The best way to implement what you're asking is to implement a constructor in class B that calls the method you require. Do not provide any constructors that do not call the method. Once you've done this, it is impossible to instantiate class B without the method being executed.

Jon Emerson
http://www.jonemerson.net/





Similar Threads
Thread Thread Starter Forum Replies Last Post
Help required zaeem SQL Server 2000 2 May 28th, 2008 12:48 AM
Some help required ! codenet C# 2005 1 September 24th, 2007 04:01 PM
is serialization required for this? hertendreef ASP.NET 2.0 Basics 0 March 24th, 2007 05:54 AM
Urgent help required! mani84 ADO.NET 1 May 19th, 2006 02:34 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.