[Solved] I cannot get the app to construct an sqlite database

You aren’t, according to the code, acessing(opening) the database. You are just instantiating the DatabseHelper in MainActivity i.e. mydb = new CrdDBHelper(this); It is not until an attempt is made to open the database (which is frequently implicit) that the database is actually created. A simple way would be to force an open when instantiating … Read more

[Solved] Simple Java Query

Whenever you need to run anything ,you always need a starting point, So Java language developers decided to have this main Method as starting point of execution. and So your code does not compile ,because these statements cannot be directly in class. Only variable declarations are allowed directly inside class,everything else needs to go inside … Read more

[Solved] Why is my app is crashing while using async task?

You are Calling Activity in a Background Thread Thats Why you are getting Error You Need to Call Like this Thread thread=new Thread(){ @Override public void run() { try { sleep(5*1000); runOnUiThread(new Runnable() { @Override public void run() { Intent i = new Intent(getApplicationContext(),MainActivity2.class); startActivity(i); } }); } catch (Exception ex) {} } }; thread.start(); … Read more

[Solved] I tried try and catch for double but it didn’t work [closed]

It’s because when you enter a number and press Enter key, scan.nextInt() consumes only the entered number, not the “end of line”. When scan.nextLine() executes, it consumes the “end of line” still in the buffer from the first input which you have provided during the execution of scan.nextInt() . Instead, use scan.nextLine() immediately after scan.nextInt(). … Read more

[Solved] Convertible or not?

You can only cast a reference if there is an “is a” relationship. There is no “is a” relationship between A and B. A is a C, and B is a C, but B is not an A. Consider: Both apples (B) and oranges (A) are fruit (C), but apples are not oranges. Note: In … Read more

[Solved] Java hashmaps go missing after a period of not using them [duplicate]

for (Location l : RunicParadise.explorerLocations.values()) { **[NPE THROWN HERE] if (l.getWorld().getName().equals(loc.getWorld().getName())) {** So the one thing that wasn’t null here was the HashMap: explorerLocations. Otherwise you would have got the NPE on the previous line where you called HashMap.values(). Any of l, l.getWorld(), l.getWorld().getName(), loc, or loc.getWorld() could be null. You’re barking up the wrong … Read more

[Solved] Create bubble sort code, but facing some errors [closed]

Thanks for your advices… Finally made it working.. thank you once again package practise; public class code{ public static void main(String[] args){ int[] Array = {5,8,6,4}; int[] newArray = new int[Array.length]; int a, b, c, d, e, f =1; for(int z : Array ){ d=0; for(int i=0; i<Array.length; i++){ a = z; b = Array[i]; … Read more

[Solved] Java – for loops being skipped

yes, your for loops ARE being skipped, since the second part of the for statement is not the break condition but the condition that has to be fullfilled for the loop to run. So it is NOT for(a = 0; a == 15; a += 3) but for(a = 0; a <= 15; a += … Read more

[Solved] i cant get my calculator to work

Try using input.next(); instead of input.nextLine(); Because input.nextLine(); advances this scanner past the current line and returns the input that was skipped. so if your input was 20, +, and 24, your method calc would get 20,24,null. 2 solved i cant get my calculator to work

[Solved] add a bigInteger value to a 2d array

For those with a maths background it is a surprising feature that System.out.println(“=” + (-3 % 4)); for example, returns -3 instead of 1 (which would be in the range [0,3]); Edit: in other words, the error message error message: Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: -8 is ultimately caused by (n % m) can return … Read more