[Solved] Integers from strings

try this code import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Tie { public static void main(String agrs[]){ Tie tie = new Tie(); String fr = “4544FF”; char[] strings = fr.toCharArray(); List<Integer>integers = new ArrayList<Integer>(); for(int i=0;i<strings.length;i++){ if(tie.validationNumber(strings[i]+””)){ integers.add(Integer.parseInt(strings[i]+””)); } } for(Integer i:integers){ System.out.println(i); } } public boolean validationNumber(String s){ Pattern pattern = … Read more

[Solved] How can I share values between a Service and Fragment in Android? [duplicate]

You can use Bundle class and put_extra data to retrieve and put. Example : put_extra Intent i = new Intent(); i.putExtra(“name_of_extra”, myParcelableObject); to read data Bundle b = new Bundle(); b = getIntent().getExtras(); Object myParcelableObject = b.getString(“name_of_extra”); solved How can I share values between a Service and Fragment in Android? [duplicate]

[Solved] Looping Srategies For Many Loops [closed]

32 million records is a large amount of almost anything, however if you are receiving the information from a Database perhaps there is a way to break it up into to parallel chunks. You could devise a strategy to execute a series of queries and combine the results. Take a look at the Java Future … Read more

[Solved] How to split an array of objects in java or Kotlin?

Based on tquadrat’s answer (in Java): public static class User{ boolean isFalse; int value; public User(boolean b, int v){ this.isFalse = b; this.value = v; } public String toString() { return “User(“+this.isFalse+”, “+this.value+”)”; } } public static void main(String[] args) { User[] users = {new User(true, 5), new User(true, 1),new User(false, 7), new User(true, 10), … Read more

[Solved] Implement inner-class-like reference behaviour? [closed]

In Java we can have (non-static) inner-classes, which seem to “behave” like having a strong-reference to their container-class and/or owner-class, but without causing memory-leak. I mean, I observed that even if both owner-class and inner-class keep strong-reference to each other, the classes are garbage-collected anyway (once no external class references them, although having reference-recursion). Yes, … Read more

[Solved] I have a date in int format DDMMYYYY, how can I separate day and month and year [closed]

As pointed out in comments, it’s most likely that input might be coming as string. You can easily parse Date from string like this: private static Date getDate(String dateStr) throws ParseException { SimpleDateFormat simpleDateFormat = new SimpleDateFormat(“ddMMyyyy”); return simpleDateFormat.parse(dateStr); } Then you can do something like this to check which date is older: String date1 … Read more

[Solved] How to add the sum of ints n to c [closed]

You can do it by using a loop and from what I understand, a seperate method, which we’ll call addSum. In addSum, we will create a for loop with the starting limits and the ending limit. public static void addSum(int start, int end) { int addMe = 0; for(; start <= end; start++) { addMe … Read more