Skip to content

Tag: java

Java array: Finding index always returns the highest

Part of one of our assignments was to generate an array and then find the sum, average, lowest, and highest values. I have all of those working, but our teacher has asked us instead to return the index of the highest and lowest values plus one (to coincide with a month number). The issue I’m running int…

Timed behaviors in Akka classic?

I am working with Akka classic, and have to setup timed behaviors – in Akka typed, I could do this using Behaviors.withTimers how do I accomplish this in Akka classic? It seems like we can create an actor in Akka using How do I use timers in this kind of initialization? Answer See the docs on Timers: ht…

DownCasting in generics in java

I am stuck in generics downcasting. Because I learn type erasure. When code compiles all parameterized types are converted to the upper bound if the bound is not defined then it changes to object. Gen Class GenDemo Class String str = strob.getob(); is converted to String implictly. how JVM converted strob.get…

Run a method for 5 sec

I would like to run a method every 1 ms in a timespan of 5 sec. Right now i am using The problem with this code is that it freezes the UI in the 5 sec timespan. Which I’m not interested in. Can a runnable or handler be used instead, and then terminated after 5 sec ? Regards! Answer You

BiGrams Spark using java

I already have the sentences in a RDD and the output looks like: RT @DougJ7777: If Britain wins #Eurovision then we have to rejoin the EU. It’s in the rules. #Eurovision2018 RT @Mystificus: Of course I’ll watch #eurovision tonight. After all, 200 million people can’t be wrong, can they? Er&#…