Click here to Skip to main content
15,888,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I done a program in java array list but I have some errors in this part i have discribed.I want the solution.

What I have tried:

void processShapeList()
				 {
				Circle c=new Circle("{12,14,16,18,20}");
				Rectangle r=new Rectangle("{22,24,26,28,30}");
				Square s=new Square("{22,34,36,38,40}");
				Triangle t=new Triangle("{52,54,56,58,60}");
				 
				 shapeList=new ArrayList<>();
				 Shape c1=new Shape();
				 shapeList.add(c1);
				 Shape r1=new Shape();
				 shapeList.add(r1);
				 Shape s1=new Shape();
				 shapeList.add(s1);
				 Shape t1=new Shape();
				 shapeList.add(c1);
				 for(Shape shape:shapeList)
				 {
					 shape.computeArea();
					 shape.display();
				 }
				 }
		 public  void main(String[]args)
		 {
				Shape1 n1=new Shape1();
				 n1.processshapeList();
		 }
			 }
Posted
Updated 23-Dec-17 5:57am
Comments
Patrice T 23-Dec-17 10:40am    
You described nothing!
Which exact error message and position.
OriginalGriff 23-Dec-17 11:48am    
We can't tell you what the problem is without you telling us what error message(s) you get, and which lines you get them on: we can't compile your code fragment in isolation and get the same results you do because we don't have access to your Shape and shape-based classes.

Use the "Improve question" widget to edit your question and provide better information.

1 solution

Look at your code, you create a number of shapes and add them to your list, but what type of shape are they, and what are their dimensions? And you never add t1, but you add c1 twice. And what is n1 supposed to be, what is Shape1? I suggest you go to The Java™ Tutorials[^] and start learning Java properly.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900