Skip to content
Advertisement

Tag: object

Setting object attributes via a array list

Basically I am working on a project where certain class attributes and names of classes are stored in a text file. The goal here is to create a list of the objects of a certain data type (in this case Car) listed in the text file (of which I have already done), and then assign these to the data types

When passing an object to another Activity using Parcelable, how can I update the object and see the changes in the original Activity?

I am working on a simple texting app in Android. In my MainActivity, when the user clicks on a conversation with someone, I send over my custom Conversation object through an intent using Parcelable. That works perfectly. Problem is, if I change any fields in this object, upon returning to the MainActivity, none of my changes are shown. As far

Creating multiple objects using the same instance

I just saw this tutorial creating multiple objects using the same instance by applying the DAO pattern and tried it in a simple console, but I always get this message java.lang.NullPointerException I’m now confused, as far as I know, a constructor can be used once only, and the object will be immutable. Kindly look at this: Fighter.java FightersDAO.java Demo.java Why

Java Bubble Sort String ArrayList Object

Can someone find why this isn’t being sorted I can’t seem to find what I have wrong? The output that is being displayed is how I input them after each other thus the sort method isn’t working… Answer There are three errors: 1. It does i++ instead of i+1. i++ means: return i then increment its value. So t1 and

How check if an Attribute(object) is null in Java

I need specific data for a report, then I gettin all information from a parent object Object1 It has many attributes, object attributes Object11, Object12, Object13, attr1, attr2… The attributes has many attributes too Object111, Object131, Object132,.. by now I got 5 level data attributes. When I send information to my report it says, Error: cause:null object1.getIdObject11().getIdObject111().getDescription; It trows error

Sort JsonArray by variable key using GSON

I am trying to sort a JsonArray in Java using GSON, I would like to sort everything inside that array via a variable key, meaning there is a string somewhere containing something that is the key that the object needs to be sorted by. Key Variable: varkey1 So it should go like like: Answer Well, you could just implement a

Advertisement