|
You continue to believe that I can guess what these error messages are - I cannot.
Also if the IDE is asking for an object (where, I have no idea) then I suspect there is something missing from your code.
|
|
|
|
|
Hello Friends
I want to extract values from HashMap.How I can do?Here is the code below:
class VFMMmaterial
{
public:
int matId;
String matName;
}
public HashMap<Integer, VFMMaterial> materialsMap = new HashMap<Integer, VFMMaterial>();
materialsMap.put(material.materialId, material);
all values of id and name r putted in materialmap
Now i tried like this to access material name:
Iterator itr = materialMap.keySet().Iterator();
While(itr.hasNext())
{
String id = itr.next();
String name = materiaMap.GetKey(Integer.ParseInt(id)).matName;
}
but it is giving error at run time and I tried also entrySet in place of keySet()
Tell me some solution.
Thanks
|
|
|
|
|
Firstly your code is not easy to read, please format it correctly. Secondly you say:
yogeshs wrote: but it is giving error at run time and I tried also entrySet in place of keySet()
but you do not explain what runtime error, and it is unlikely that we can guess it!
|
|
|
|
|
I am getting iterator of Hashmap hmap like this:
Iterator itr = hmap.keySet().Iterator();
Now,I m running this loop to get next value like this:
while(itr.hasNext())
{
Object key = itr.next();
}
Now,the itr.next is returning the object type.But to get the value by using that key needs int type not object type,that code is here:
while(itr.hasNext())
{
Object key = itr.next();
String name = hmap.get(key).materialname;
}
so what can I do?
I want to tell that hmap is having two parameters:
hmap<int id,class="" material="">
Thanks In Advance.
Yogesh
|
|
|
|
|
First thing: as already mentioned a LOT of times, please format your code properly. Take some time to make your message readable and understandable, you will definitively get much more answers.
Second point, the previous poster asked you about which runtime error you receive. You still didn't provide that information.
Now concerning your problem: why do you iterate over the keys if you need the values ? Instead of doing this:
Iterator itr = hmap.keySet().Iterator();
Do this:
Iterator itr = hmap.values().Iterator();
This way you will iterate over the values of your map. You will still need to cast your object to the correct type if you didn't use generics when declaring your map.
yogeshs wrote: I want to tell that hmap is having two parameters:
hmap
I don't get that part of your message. Could you please clarify what you are trying to do ?
|
|
|
|
|
|
I'm using netbean IDE to create a jsp file which will collect data from another jsp file which contains a form for people to enter data.
However, when I run the jsp file, it gives me the following error:-
There are no servlet mappings specified in web.xml.
org.apache.jasper.JasperException: An exception occurred processing JSP page /processAddMember.jsp at line 34
31: strContact = request.getParameter("txtContact").trim();
32: strDOB = request.getParameter("txtDOB").trim();
33: strGender = request.getParameter("txtGender").trim();
34: strType = request.getParameter("txtMember").trim();
35: strRemarks = request.getParameter("txtRemarks").trim();
36: strCreateRecordSQL = "INSERT INTO tblMember ";
37: strCreateRecordSQL += "(strFullNameME,strEmailME,strAddressME, strNRICNoME, strContactME, "
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
root cause
java.lang.NullPointerException
org.apache.jsp.processAddMember_jsp._jspService(processAddMember_jsp.java:87)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.20 logs.
Pls help me. It's urgent. tks.
|
|
|
|
|
karengsh wrote: org.apache.jasper.JasperException: An exception occurred processing JSP page /processAddMember.jsp at line 34
The above should point you to the cause; it looks as though txtMember may not have been initialised correctly.
|
|
|
|
|
May I know how did you identify the error?
|
|
|
|
|
karengsh wrote: May I know how did you identify the error?
Simply by reading the error messages. Your original post showed the following (cut out the unimportant parts):
org.apache.jasper.JasperException: An exception occurred processing JSP page /processAddMember.jsp at line 34
34: strType = request.getParameter("txtMember").trim();
This shows that the statement on line 34 caused an error
root cause
java.lang.NullPointerException
A NullPointerException usually indicates that some variable has not been initialised correctly, or has been corrupted or otherwise changed to make it invalid.
From this (and the stack trace) you need to work backwards through your program to identify were this may have occurred.
|
|
|
|
|
Hello Friends
Do anyone of you know about material(.mtl) file?
Do anyone of you read it?
I read most of the file but some option are not getting through java classes like map_ka(ambient textures),map_ks(specular textures).
Thanks In Advance.
Regards
Yogesh
|
|
|
|
|
hi all
as u know java is using call by reference with objects
how can i instead call by value for objects??
thanks in advance
|
|
|
|
|
Hi,
You can't pass an object by value. The best approximation would be to pass a clone of the object.
And why would you need to pass by value?
|
|
|
|
|
i have arraylist of objects <schedules>
and i wrote a method that take one object <schedule> from the arraylist
and return a modified object <another schedule="">
the problem is after calling the method all objects in the arraylist changed to the new value!!!
when i debuge my program i realized that all objects (in the array list and the returning object) have the same id (i'm using eclipse), which is suppose to be unique
and because of that any changes to object are applied to all version
i don't know way
can you help please??
|
|
|
|
|
from what you told, but did not show, it sounds like you are only creating a single object, and have a loop that (1) modifies it somehow and (2) adds its reference to the arraylist, resulting in a large number of identical references to the single object in its final state.
Check: is the "new Whatever(...)" inside or outside your loop?
If that does not help, then I suggest you show the relevant code.
|
|
|
|
|
my code is very long, that's why i don't write it before
i'm writing a program for multiprocessor using genetic algorithm
<br />
ArrayList <schedule> POP=new ArrayList <schedule>(); <br />
for(int i=0;i<10;i++)<br />
POP.add(generate_schedule());<br />
<br />
ArrayList <schedule> TMP=new ArrayList <schedule> ();<br />
<br />
<br />
for(int j=0;j < NPOP.size()/2;j++)<br />
{<br />
schedule s1=NPOP.get(j);<br />
<br />
schedule s2=NPOP.get(j+(POP.size()/2));<br />
<br />
Random rand=new Random();<br />
double r=rand.nextDouble();<br />
if(r<=CrossOver_prob)<br />
{<br />
ArrayList <schedule> result=new ArrayList <schedule>();<br />
result=crossover(s1,s2);<br />
TMP.add(result.get(0));<br />
TMP.add(result.get(1));<br />
}<br />
else<br />
{<br />
TMP.add(s1);<br />
TMP.add(s2);<br />
}<br />
<br />
}<br />
<br />
for(int j=0;j < TMP.size();j++)<br />
{<br />
System.out.println("schedule"+j);<br />
Random rand=new Random();<br />
double r=rand.nextDouble();<br />
if(r<=Mutation_prob)<br />
POP.add(Mutation(TMP.get(j)););<br />
else<br />
POP.add(TMP.get(j));<br />
}
my problem is on the bold line when calling mutation all schedules in TMP is changed
hope its clear now
|
|
|
|
|
Sorry, that code is hardly readable; please use PRE tags, not CODE tags, so we get indentation and good contrast. You can still edit the existing message.
Furthermore, what needs to be checked is how the values or objects get created that you are adding to the arraylist, hence one has to inspect Mutation(), and whatever is used to create the entries in NPOP (as those will end up in TMP).
|
|
|
|
|
Your question is still not very clear because you didn't provide the function prototype (we can only see the content of the function, not the parameters which are passed).
Anyway, in Java whenever you manipulate an object, it is similar as using a pointer to the object. So, when you pass the object to a function, you pass the pointer and not a copy of the object. If you really need to make changes in a copy of the object, then you have to create a new instance of the object yourself.
There's no such thing as passing by value in java.
|
|
|
|
|
Luc Pattyn
Cédric Moonen
thank u all for your reply
its clear now that's my problem was i don't create a new insantce of my objects
but i referenced to existing object
schedule s = POP.get(i);
where POP is arraylist of schedules
again thank u for ur help
|
|
|
|
|
1.in the same class, you can not directly create objects
2.in other classes, you must create an object to call by value for objects
3.the class can be defined as static ,or you can directly call the class' name
April
Comm100 - Leading Live Chat Software Provider
modified 27-May-14 8:52am.
|
|
|
|
|
Hello Friends
I m reading a .mtl file(material file) by using Java 3D API.
I am setting the ambient,diffuse and specular color in material.
but when I m loading object without any textures then illumination is coming right.But If I load an Oject with Textures by using TextureLoader then Illumination is not coming.
And I m also enabling material.setLightingEnable while setting Illumination.
Any ideas???
Thanks & Regards
Yogesh
|
|
|
|
|
is ti correct order? first load object, then illumination?
I never finish anyth...
|
|
|
|
|
Obviously,first of all I m loading object then m reading mtl file and as i came to across different tokens in mtl file I am reading tht.First I m applying color to material,then illumination then textures.
Any Ideas??
|
|
|
|
|
Hello friends
I m trying to read a .mtl(material file).For that I m using TextureLoader.
I am able to load diffuse Texture Using:
TextureLoader textureLoader = new TextureLoader(textureImage, TextureLoader.GENERATE_MIPMAP);
currentAppearance.setTexture(textureLoader.getTexture());
textureImage is BufferedImage.
Now ,I want to load ambient map,opacity map and specular map.
So is there any other flag in same class TextureLoader or do i need to use diferent class?
Thanks iN advance
Regards
Yogesh
|
|
|
|
|
After getting TextureLoader,we need to apply TextureAttributes and then TransparenyAtttributes to Appearance.
Anyway,Thanks foe viewing My question.
Regards
Yogesh
|
|
|
|