Skip to content

Tag: java

Determine the Object (book) that appears first alphabetically

I was tasked with creating my own linked list class, using a book class i made. One of the questions was to Determine the book that appears first alphabetically. i was able to sort the Linked list alphabetically using bubble sort(i know its not efficient but im still new) here is the code. my problem is i onl…

Getting the Activity inside Adapter in Android

I am trying to access the activity on which my Imageview is, so I can use the URL of an Image of type SVG and display it to the user using the GlideToVectorYou library. But when I try to get access to the activity using R.layout.activityname, a syntax error appears. this is the code that I’m using Thank…

Sort list of strings as BigDecimal in reverse order in Java

I need to sort list of strings comparing them as BigDecimal. Here is what I tried: Can I somehow do this without explicitly specifying the types? Answer You can do it like this. prints You could also do it like this but need to declare the type parameter as a String. But here is the way I would recommend doin…

GSON flat down map to other fields

So I have an Android app which uses Retrofit for API. I have a class like which looks like: When GSON creates a JSON it looks like: Would it be possible to change JSON serialization to: Thanks. Answer Here is how Gson could be used to implement the flattening: I’ve put some comments explaining “wh…