[Solved] Add the values on ArrayList in Android [closed]

[ad_1] After getting value from intent: ArrayList<String> arrayList = new ArrayList<String>(); valueaddlist = (Button) findViewById(R.id.valueaddlist); valueaddlist.setOnClickListener(new OnClickListener() { public void onClick(View v){ arrayList.add(product_id); arrayList.add(product_title); arrayList.add(product_image); arrayList.add(product_price); arrayList.add(product_desc); } valuedisplaylist = (Button) findViewById(R.id.valuedisplaylist); valuedisplaylist.setOnClickListener(new OnClickListener() { public void onClick(View v){ Intent intent = new Intent(this,AddedListProducts.class); intent.putStringArrayListExtra(“arrayList”, (ArrayList<String>) arrayList); startActivity(intent); } May be this will help you. … Read more

[Solved] Main method not found in class Base [closed]

[ad_1] If you want to run the Base class, you should create a class Base (in a File Base.java, and delete the file Child.java before…) and write this inside it: package my.stuff; class Child extends Base { void get(int x,int y) { this.x=x; this.y=y; } } public class Base { int x; int y; void … Read more

[Solved] Android: Division and subtraction always equal 1.0

[ad_1] You are reading the value from display1 twice, you forgot to change the reading of number2 to display2. Replace: number2 = Double.valueOf(display1.getText().toString()); with number2 = Double.valueOf(display2.getText().toString()); Your function would end up being: if(minu){ number1 = Double.valueOf(display1.getText().toString()); number2 = Double.valueOf(display2.getText().toString()); display1.setText(“”); display2.setText(“”); displaySymbol.setText(“”); answer = number1 – number2; display1.setText(Double.toString(answer)); } 0 [ad_2] solved Android: Division … Read more

[Solved] Importing classes Java [closed]

[ad_1] Which java version do you use? If I look at the scanner documentation, there are several constructors, but no default constructor. You need to pass some arguments for the call “new java.util.Scanner(xxxx)” See https://docs.oracle.com/javase/8/docs/api/java/util/Scanner.html [ad_2] solved Importing classes Java [closed]

[Solved] I’m a self-taught programmer so did i understand these concepts? can someone include example too [closed]

[ad_1] These things all work together. An object is something that is self-sufficient, it keeps track of its own state. Encapsulation enforces that separation, the object publishes methods that other objects call, but those methods are responsible for modifying the object’s state. In oo systems that use classes the class is a template for creating … Read more

[Solved] my else if statement isnt working in my tic tac toe program [duplicate]

[ad_1] if (currentstate == you_win){ System.out.println(“‘X’ Won!!”); else if (currentstate == comp_win) System.out.println(“‘O’ won!!”); else if (currentstate == draw) System.out.println(“It’s a Draw :(“); } Take a look at this line (and I removed some extraneous code to make this easier to see): if (currentstate == you_win){ else if (currentstate == comp_win) //… } Looking at … Read more

[Solved] Why does compiler gives this exception [closed]

[ad_1] First off, a few things to note. First, compilers do not give Exceptions, they give compilation errors – what you are experiencing is at runtime, not compile-time. Second, fileIn.exists() != false is equivalent to fileIn.exists(), which is easier to read. The actual problem you’re receiving is because your condition is false – which implies … Read more

[Solved] Converting a string into an List [closed]

[ad_1] A neat way to do it is String s = “[1,2,3]” s=s.sbustring(1,s.length-1); List<Long> numLongs = new ArrayList<Long>(); for(String eachString: s.split(“,”)){ try { numLongs.add(Long.parseLong(eachString)) } catch (NumberFormatException e){ System.out.println(“failed to convert : “+s); } } 0 [ad_2] solved Converting a string into an List [closed]

[Solved] Android, NullPointerException

[ad_1] You shouldn’t be setting the onClickListener for your button within the button itself, instead it should be set in the Activity that makes use of both of your buttons. Likewise, findViewById() in your example can’t find the TextView as it’s not within the same scope as your button. In absence of code from your … Read more