[Solved] Parsing multidimensional JSON in java

Try to use google GSON Library it will fullfill the same requirements as you want. Here is the Link for a sample tutorial implemented in android how ever the language used is Java All you have to do is make a data model of same type and as members in JSOn. try the example in … Read more

[Solved] App is crashing when I convert string to int

check if its not null then cast to integer: try { if(description[i][j]!=null && description[i][j].length()>0){ id=Integer.parseInt(description[i][j]); Toast.makeText(getApplicationContext(),id, Toast.LENGTH_SHORT).show(); } } instead of try { id=Integer.parseInt(description[i][j]); } i hope its work but description[i][j] must returns string. if id getting value then print toast.otherwise no toast print.. 2 solved App is crashing when I convert string to int

[Solved] “Given 2 ints, a and b, return true if one if them is 10 or if their sum is 10.” How can I apply real numbers

One of the easiest option you have is java.util.Scanner Defention: A simple text scanner which can parse primitive types and strings using regular expressions. A Scanner breaks its input into tokens using a delimiter pattern, which by default matches whitespace. The resulting tokens may then be converted into values of different types using the various … Read more

[Solved] Unexpected result when copying an array in Java

System.arraycopy(scores, 2, scores, 3, 2); This copies 2 items from source index 2. therefore {3, 4} into destination position 3. Since your source and destination arrays are the same you’re overwriting the 5 with the 4 {3 4} <== items copied { 1, 2, 3, 4, 5, 6} <== original 0 1 2 3 4 … Read more

[Solved] how to avoid this ClassCastException? [closed]

You have an intermittent exception being thrown from a Swing GUI which highly suggests that this is a concurrency/threading issue. Are you starting the GUI on the Swing event dispatch thread? If not, please be sure to do this, especially with some Look & Feels such as Nimbus. In other words — create your GUI … Read more

[Solved] send string data from Activity to fragment [closed]

Add below code inside listview itemclick listner in activity: Tozihat gTozihat = new Tozihat().newInstance(“Data”); getSupportFragmentManager().beginTransaction() .replace(R.id.textViewTozihat, gTozihat).commit(); Inside your Fragment : private static final String TYPE = “DATA_KEY”; public static Tozihat newInstance(String type) { Tozihat fragment = new Tozihat(); Bundle args = new Bundle(); args.putString(TYPE, type); fragment.setArguments(args); return fragment; } 3 solved send string data … Read more

[Solved] 2-D array Friends of Friends List

Why not try something like this. Of course, i have taken a bit of freedom on the design as you didnt provide any code. Hope this helps! private static Set<Node> getNodesFollowAllEdges(Node node) { Set<Node> nodes = getNodesFollowAllEdges(node, new HashSet<>()); // remember to remove the original node from the set nodes.remove(node); return nodes; } private static … Read more

[Solved] List table=null; in java

This code declares a variable tables of type List<Data>, and initialize it to null. (I change your data to Data to match the java convention) I think you’re in trouble with the <Data> part. So let me say: List is a generic class, which can be parametrized with another type. You can write List<String> or … Read more

[Solved] How to populate int array dynamiclly by a given range? [closed]

If you are looking for a code that generates random numbers between the given range, the below code is for you import java.util.Scanner; import java.util.Random; public class Insert { static Scanner input=new Scanner(System.in); public static void main(String [] args){ Random rand=new Random(); int max,min; System.out.println(“enter the maximum number”); max=input.nextInt(); System.out.println(“enter the minimum number”); min=input.nextInt(); int … Read more

[Solved] Please some information regarding Java code [closed]

a = 0 is wrong since a is an int array. You’re probably looking for a counter variable. It could be like this: boolean existsData = false; for(int i=0; i<arr.length; i++) //arr[i] = 0 means assign 0 to arr[i] //note that I’m using different (!=) existsData = (arr[i] != 0); if (existsData) { break; } … Read more

[Solved] having errors in a java function

There is a compile error in the Grocery_Items class. You’ve commented the qty field: // private quantitypanel qty; // A panel for quantity Remove the comment private quantitypanel qty; // A panel for quantity and you won’t have any more error messages attached to it [qty]. 1 solved having errors in a java function

[Solved] creating an object outside main and user defined method scope gives “Exception in thread “main” java.lang.StackOverflowError” [closed]

Remove the line Sample obj3 = new Sample(); because that will result in an endless loop (creating an instance of Sample while during the creation of an instance of Sample), causing your StackOverflowError. And please dont post code as an image. 4 solved creating an object outside main and user defined method scope gives “Exception … Read more