[Solved] Write a program which accepts two integers as a minimum and maximum limit and calculates total of how many 1s were their within the limit

I strongly advice looking into the math of your problem and come up with a clever algorithm that you then implement. The 1s are far from randomly distributed in a range of numbers that are count up 😉 However there is always the brute force approach. (This is just to show a possibility and one … Read more

[Solved] JsonArray convert to java code [duplicate]

For above json you must have this classes below: Example.java package com.example; import javax.annotation.Generated; import com.google.gson.annotations.Expose; public class Example { @Expose private To to; public To getTo() { return to; } public void setTo(To to) { this.to = to; } } To.java package com.example; import java.util.ArrayList; import java.util.List; import javax.annotation.Generated; import com.google.gson.annotations.Expose; public class To … Read more

[Solved] How to convert Money to BigDecimal in Java? [closed]

If Money type is the one as suggested by Alexis C. in a comment above, from the Javadoc: getAmount java.math.BigDecimal getAmount() Get the amount of money as a BigDecimal. Returns: the BigDecimal amount So you should just call BigDecimal big = money.getAmount(); Otherwise if Money is a of a different type or your own custom … Read more

[Solved] explain why java does not support the concept of executable file [closed]

Because exe’s have to be compiled for specific environments. Oracle compiles their runtime (JRE) for different operating systems, which interprets your Java file anywhere that has a JRE installed. You can however make an installer for it: Create Windows Installer for Java Programs 4 solved explain why java does not support the concept of executable … Read more

[Solved] Need some help in Java String

I’m not sure if i understood you well but try following code: public class Main { public static void main(String[] argv) { String input = “gudmor,ningeveryone,Have a great day,thankssssssssssss”; String[] firstSplit = input.split(“,”); List<String> result = new ArrayList<>(); String[] tmpArray; for (String elem : firstSplit) { if (elem.length() <= 10) { result.add(elem); } else { … Read more

[Solved] How to split a string if any chracter is found in java

You can use String‘s methods replaceAll and split together here. String one = “show ip interface brief | include 1234**\n Gi1/23.1234 xxx.225.xxx.106 YES manual up up”; String[] tokens = one.replaceAll(“[^\\n]+\\n\\s*”, “”).split(“\\s+”); System.out.println(Arrays.toString(tokens)); Output [Gi1/23.1234, xxx.225.xxx.106, YES, manual, up, up] solved How to split a string if any chracter is found in java

[Solved] match two string and replace non-match char to + in java [closed]

Your solution works but with a slight modification like below. Remove the (?i) part if you dont want to take case sensitivity into account. public class StringReplacer { public static void main(String[] args) { String str1 = “New York”; String str2 = “New Jersy”; for(String s : str1.split(“(?i)[” + str2 +”]”)){ if(s.trim().length() > 0){ str1 … Read more

[Solved] Java Multiple Choice Inquiry [closed]

It doesn’t print anything. when we invoke the method printVals() the value of k is 4 and therefore the expression k < 1 evaluates to false and method ends. It never goes to recursive call or print statement. However if you change the expression to if(k > 1) then it’ll print “Ann Cal Amy Ann” … Read more