Skip to content
Advertisement

Tag: object

How to pretty print a complex Java object (e.g. with fields that are collections of objects)? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations. Closed 5 years ago. The community reviewed whether to reopen this question 4 months ago and left it

How to find the longest string object in an arrayList

Here is is my problem, I have to explain a lot, because it’s a quite complicated. I have created an arrayList<Word>, that contains strings as objects. In my case, I have three classes, all working together, that is supposed to represent a dictionary. The first class is called “Word”, it has a constructor, and has simple methodes like .length, adds

Getting values from one Array List using objects of another array list java

I have 3 ArrayLists. Students (ID, Name, Program) Courses (ID, Name, Credit Hours) StudentCourses (StudentId, CourseID) I am searching from StudentCourses by passing the StudentID and getting the courses registered with his/her name. My StudentCourse ArrayLIst has objects like this 49 (Student ID) CS233(Course ID) 49 (Student ID) CS231(Course ID) When a user searches for a student, say I’m searching

How to sort an array of objects in Java?

My array does not contain any string. But its contains object references. Every object reference returns name, id, author and publisher by toString method. Now I need to sort that array of objects by the name. I know how to sort, but I do not know how to extract the name from the objects and sort them. Answer You have

Can Java primitives be considered light objects [closed]

Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 8 years ago. Improve this question As per this answer here both java objects and primitives go on heap. So from the point of view of JVM,

Duplicating objects in Java

I learned that when you modify a variable in Java it doesn’t change the variable it was based on I assumed a similar thing for objects. Consider this class. After I tried this code I got confused. Please explain to me why changing any of the objects affects the other one. I understand that the value of variable text is

When a subclass is instantiated, is only one object created?

Since many constructors also call the superclass constructor, it seems like one could think that both the subclass and the superclass are instantiated when a subclass is instantiated; i.e. more than one object is created. Is still just one object created? Thank you Answer Just one object, even if the super’s constructor is called you are just performing additional instantiation

Advertisement