Joseph Arnold

Ranch Hand
+ Follow
since Oct 05, 2010
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
9
Received in last 30 days
0
Total given
4
Given in last 30 days
0
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(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyUtils.java:1789)
at org.apache.commons.beanutils.PropertyUtils.setNestedProperty(PropertyUtils.java:1684)
at org.apache.commons.beanutils.PropertyUtils.setProperty(PropertyUtils.java:1713)
at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:1019)
at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)
at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:467)
at org.apache.struts.chain.commands.servlet.PopulateActionForm.populate(PopulateActionForm.java:50)
at org.apache.struts.chain.commands.AbstractPopulateActionForm.execute(AbstractPopulateActionForm.java:60)
at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)

My form bean: ExpenseForm.java



And my home.jsp :

Can somebody please help me out? I have been stuck on this for almost the entire day
10 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.
10 years ago
For struts, I suggest you read 'struts for dummies' or 'struts survival guide'.
10 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,

hs.add(20)
hs.add(25)

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??