Joseph Arnold

Ranch Hand
+ Follow
since Oct 05, 2010
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Joseph Arnold

When two classes are tightly coupled, the classes can access each others properties directly. To make them loosely coupled, we have to restrict direct access to a class's properties and must make use of getter/setter methods.
If the class' instance variables are made private and if they can be accessed only through getter/setter methods, it is an indicator of loose coupling with the other classes.
Actually what I meant was that the value of i will not be assigned the value returned by the function 'Math.ceil(8.4f);' till the super class constructor has finished executing. Sorry, for putting it across the improperly.
Anyway thanks for explaining object creation process clearly.
When you create a new object of type MySub, first the super class constructor is called before executing any function of the sub class.
And in the super class, you are calling the overridden method disp() in the sub class. At that time only the memory is allocated for i but the value is not assigned yet as the function Math.ceil(8.4f) hasn't executed yet.
Remember that functions in the sub class will be executed only after the super class constructor has finished executing .
I am learning the struts framework by building a simple account management application. I have a login page from where valid users are logged in to a homepage(home.jsp) where they can add a new expense and some details. I get the following exception upon submitting the expense form.

java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(
at org.apache.commons.beanutils.PropertyUtils.setNestedProperty(
at org.apache.commons.beanutils.PropertyUtils.setProperty(
at org.apache.commons.beanutils.BeanUtils.setProperty(
at org.apache.commons.beanutils.BeanUtils.populate(
at org.apache.struts.util.RequestUtils.populate(
at org.apache.struts.chain.commands.servlet.PopulateActionForm.populate(
at org.apache.struts.chain.commands.AbstractPopulateActionForm.execute(
at org.apache.struts.chain.commands.ActionCommandBase.execute(
at org.apache.commons.chain.impl.ChainBase.execute(
at org.apache.commons.chain.generic.LookupCommand.execute(
at org.apache.commons.chain.impl.ChainBase.execute(
at org.apache.struts.chain.ComposableRequestProcessor.process(
at org.apache.struts.action.ActionServlet.process(
at org.apache.struts.action.ActionServlet.doPost(
at javax.servlet.http.HttpServlet.service(
at javax.servlet.http.HttpServlet.service(
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
at org.apache.catalina.core.StandardWrapperValve.invoke(
at org.apache.catalina.core.StandardContextValve.invoke(
at org.apache.catalina.core.StandardHostValve.invoke(
at org.apache.catalina.valves.ErrorReportValve.invoke(
at org.apache.catalina.core.StandardEngineValve.invoke(
at org.apache.catalina.connector.CoyoteAdapter.service(
at org.apache.coyote.http11.Http11Processor.process(
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(

My form bean:

And my home.jsp :

Can somebody please help me out? I have been stuck on this for almost the entire day
12 years ago
Well, by saying 'advanced' part, he is only referring to advanced Java i.e J2EE,JSP,Servlets all come under advanced Java right? Having done with core Java, he wants to go into advanced Java or J2EE. I suggest Prashant to try build simple web applications using Servlets and Jsp before delving into framweworks.
12 years ago
For struts, I suggest you read 'struts for dummies' or 'struts survival guide'.
12 years ago
I had passed the OCJP exam in the third week of December and I haven't recieved he certificate yet. Can someone help me out in what I have to do now?

ordered by index means: if i ask for collection[0] i will get the element at zero, it may or may not have been the first element added to the collection.

ordered by insertion order means: if i ask for collection[0] i will get the first element that was added to the set. the first element added to the set will always reside in collection[0].

Yes. You are right.
Now that you have got your voucher, call up a prometric center in your city and find out if you can register and book a spot on the day you want to give the exam or if you have to do it in advance. It depends on the prometric center as they have their own time slots. Most likely they would ask you to book in advance if you are giving the exam on a weekend.
Floozel can have several Floozets mean there can be several instances of Floozets in floozel. Well, both options illustrate the same. Whether Floozet is a class type or an interface type does not matter. We must only ensure that there is some appropriate collection of floozets in a floozel.

Object obj = new Horse("Zippo");

Here is the reference type is Object and hence you can only access members of object and not horse.
If you want to use a access a method/property of Horse, you should simple use the horse reference type itself.
Look at it this way, the only reason Java allows you have to have a base class refer to a sub class type is to make use of polymorphism. Conceptually, a base class reference is used to access a property that is common to all subclasses and not a property pertaining to a particular sub class(here name belongs only to horse).
Common properties of several classes are identified and are put in a common class called the Base class. That is the idea behind inheritance.
Ordered by index is similar to contents in an array. Here retrieval of elements from the collection is based on the index. You can add or remove elements from any indexed position whereas in the case insertion order, you cannot access elements in any order. Here retreival of elements is similar to that of a stack or a queue.
You are assigning i2 to 33 after inserting i2 into the LinkedHashSet. Now when you try to remove i2, you are actually trying to remove a 33 from the Set which doesn't exist in the Set.
It is similar to,


and then
hs.remove(33) // 33 doesn't exist in hs. So nothing is removed!!3

When you insert i2 into the set, the set hs stores 25 in it. So when you reassign i2 to 33, the value in hs is unchanged and is 25 only.
In this case, T is of type number. The function can take any parameter that is of type T or is a sub class of T.
Ah! The confusion is back again... So the question is whether inheriting a variable different from 'having' the variable??