Results 1 to 5 of 5
Thread: Java Templates
- 02-10-2012, 07:49 PM #1
Member
- Join Date
- Feb 2012
- Posts
- 3
- Rep Power
- 0
Java Templates
I've defined a class that has the following body:
class Condition {
...
ArrayList<? extends Condition> subconditions;
...
Condition (..., ArrayList <? extends Condition> subconditions) {
...
}
...
}
I also have a function that contains the following lines:
...
Condition condition = new Condition (..., new ArrayList<Condition> ());
...
Condition subcondition = DatabaseParser.parseConditionElement (...)
condition.subconditions.add (subcondition);
...
I'm getting the following error when I try to compile the above source code.
[javac] Compiling 18 source files to /home/llee/projects/android_app_projects/options/bin/classes
[javac] /home/llee/projects/android_app_projects/options/src/org/k4health/Ace/DatabaseParser.java:82: cannot find symbol
[javac] symbol : method add(org.k4health.Ace.Condition)
[javac] location: class java.util.ArrayList<capture#548 of ? extends org.k4health.Ace.Condition>
[javac] condition.subconditions.add (subcondition);
[javac] ^
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 1 error
I'm inexperienced with Java templates and do not know what this error message means. Any help would be greatly appreciated.
- 02-10-2012, 09:20 PM #2
Re: Java Templates
The compiler can not find an add() method that takes a org.k4health.Ace.Condition class object as a parameter.cannot find symbol
symbol : method add(org.k4health.Ace.Condition)
Where is this method defined?
- 02-10-2012, 09:51 PM #3
Member
- Join Date
- Feb 2012
- Posts
- 3
- Rep Power
- 0
- 02-10-2012, 09:53 PM #4
Re: Java Templates
Can you make a small complete program that shows the errors?
- 02-10-2012, 11:10 PM #5
Member
- Join Date
- Feb 2012
- Posts
- 3
- Rep Power
- 0
Re: Java Templates
Java Code:package org.k4health.Ace; import java.io.Serializable; import java.util.ArrayList; // Represents medical conditions. public class Condition implements Serializable { ArrayList<? extends Condition> subconditions; Condition (ArrayList<? extends Condition> subconditions) { this.subconditions = subconditions; } } public class DatabaseParser { static Condition parseConditionElement (Element conditionElem) { Condition condition = new Condition ( new ArrayList<Condition> () ); Condition subcondition = new Condition (new ArrayList<Condition> ()); condition.subconditions.add (subcondition); // Compiler error occurs here. return condition; } }Last edited by Norm; 02-10-2012 at 11:15 PM. Reason: added code tags
Similar Threads
-
Using Generic Methods like Templates?
By slider57 in forum New To JavaReplies: 4Last Post: 08-04-2011, 08:16 AM -
Text-field templates.
By jdipierro in forum New To JavaReplies: 4Last Post: 05-14-2010, 12:48 AM -
HELP! - Eclipse Templates
By protocos in forum EclipseReplies: 1Last Post: 03-06-2009, 02:31 AM -
Templates JSP
By Eric in forum JavaServer Pages (JSP) and JSTLReplies: 2Last Post: 07-04-2007, 07:42 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks