Question
i tried to run this program Jgrasp, but it does not run. I don't know. Could you fix it for me please thatnks. and this
i tried to run this program Jgrasp, but it does not run. I don't know. Could you fix it for me please thatnks. and this requarization:( Write program to store bunch of Rectangles ans squares in an arrlylist. use object serialization to write the arrylist into a fle.read the arrylist object from the file. print the arrylist.) this is the code that I wrote.
importjava.io.*; importjava.util.ArrayList; publicclassSerializableObjects { staticclassRectangle implementsSerializable { privatedoublewidth, length; publicRectangle() { } publicRectangle(doublewidth, doublelength) { this.width = width; this.length = length; } publicdoublegetWidth() { returnwidth; } publicvoidsetWidth(doublewidth) { this.width = width; } publicdoublegetLength() { returnlength; publicvoidsetLength(doublelength) { this.length = length; Override publicString toString() { return"Rectangle{"+ "width="+ width + ", length="+ length + '}'; } staticclassSquare implementsSerializable { 4privatedoubleside; publicSquare() { publicSquare(doubleside) { this.side = side; publicdoublegetSide() { returnside; } publicvoidsetSide(doubleside) { this.side = side; } @Override publicString toString() { return"Square{"+ "side="+ side + '}'; } } }
Main:
publicstaticvoidmain(String[] args) throwsIOException, ClassNotFoundException { ArrayList
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started