[Solved] Make uniform colored Bitmap [closed]

in an inefficent way: Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { bitmap.setPixel(i, j, Color.argb(255, 255, 0, 0)); } } for a full red bitmap 1 solved Make uniform colored Bitmap [closed]

[Solved] Java – log in, store users in database

I think you’re looking for something like spring-security or app server proprietary ways of authenticating users stored in a database (like Tomcat’s JDBCRealm). But frankly, if you know nothing about spring-security or even spring, and want to avoid proprietary solutions, writing your own servlet filter which goes to the database is quite an easy solution. … Read more

[Solved] How to check how many times one number appears in the second number? [closed]

int count=0; if((second%10)==first){ count++; } if(Math.round((second/10))==first){ count++; } System.out.println(first+” occurs “+count+” times in “+second); Maybe this can help you ;), replace your last println by this 8 lines 😉 but as shmosel sait in comment, be carreful it’s int first = n.nextInt(10); int second = n.nextInt(90)+10; 0 solved How to check how many times one … Read more

[Solved] Prime numbers with input from keyboard

Track the number of primes you have printed, which is not x. Check whether you have printed enough. import java.util.Scanner; public class PrimeNumbers{ public static void main(String[] agrs){ int max; int numPrinted=0; Scanner sk = new Scanner(System.in); System.out.print(“How many prime numbers you want to display? “); max = sk.nextInt(); System.out.print(“Prime numbers: “); for(int x =2; … Read more

[Solved] How to print characters and integers from a char array [closed]

You really should do some research on your own first (and if you have, show evidence). However, here is a solution. int halfLength = onlyArr.length / 2 + (onlyArr.length % 2); for(int i = 0; i < halfLength; i++){ System.out.printf(“%c,%d%n”, onlyArr[i], (int)(onlyArr[i + halfLength] – 48)); } When printing the integer, you have to subtract … Read more

[Solved] How to iterate complicated List of Maps containing Maps

How about this? ArrayList<HashMap<String, HashMap<String, String>>> list = new ArrayList<>(); for (HashMap<String, HashMap<String, String>> m : list) { for (Map.Entry<String, HashMap<String, String>> e : m.entrySet()) { String key1 = e.getKey(); for (Map.Entry<String, String> me : e.getValue().entrySet()) { String key2 = me.getKey(); String value = me.getValue(); } } } Note that you really should be using … Read more

[Solved] Recursive function without loop

First thing you should consider when using recursion is the exit state; which means when the function will be exit public static int findMin(int[] numbers, int startIndex, int endIndex) { if(startIndex == endIndex){ return numbers[startIndex]; } int min = findMin(numbers, startIndex+1, endIndex); return numbers[startIndex] < min ? numbers[startIndex] : min ; } 0 solved Recursive … Read more

[Solved] ‘void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)’ on a null object reference &

So for the menu item, we do in this way 1) To specify the options menu for an activity, override onCreateOptionsMenu(). In this method, you can inflate your menu resource:- @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.game_menu, menu); return true; } 2)Handling click events: You can match this ID against known … Read more

[Solved] Finding The Area Of A Triangle

The reason you’re not getting a correct answer is because you are not finding the sides correctly. However, after finding the side length you can get the answer. Here is what I did: public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println(“Enter three points for a triangle:”); //Store the values in an … Read more

[Solved] How to compare List of Long and return the number of matches [closed]

You can try something like this: Collection<Integer> id = Arrays.asList(2316, 2317, 2318); Collection<Integer> existingId = Arrays.asList(1004, 1762, 1892, 1342, 1942, 2316); Collection<Integer> similar = new HashSet<Integer>( id ); similar.removeAll( existingId ); System.out.println(“Different:”+similar); System.out.println(“#of items that are differnt:”+similar.size()); 1 solved How to compare List of Long and return the number of matches [closed]