[Solved] java array method to return an array [closed]

Assuming you want to return an array with two values (namely the min and the max), you can build that in one line like return new int[] { min, max }; I would also prefer Integer.min(int, int) and Integer.max(int, int) for finding those values. Like, static int[] records(int[] score) { int max = score[0], min … Read more

[Solved] How to evaluate this expression [duplicate]

According to the JLS, subexpressions are evaluated from left to right. That’s why the first term is evaluated to 5, the second one is evaluated to 6 and third one is evaluated after the second one so it gives 6. That’s why the sum is 17. 8 solved How to evaluate this expression [duplicate]

[Solved] How do I store the data which is passed though the browser link in a mySQL database? [closed]

you are actually looking for _GET[‘message3’]variable.. do something like that $message = _GET[‘message3’] ; if(isset($message){ $sql = insert your $message variable in database here run the query } etc.. and you are done I assume that you are learning over your localhost and you got the file Sent.jsp solved How do I store the data … Read more

[Solved] Printing a statement using threads in Java [closed]

I think your problem is in this method: synchronized void PrintMsg(String msg) { System.out.println(msg); try { wait(); } catch (InterruptedException e) { System.out.println(“Exception”); } System.out.println(msg); notify(); } The thread that call it are going to call wait() which causes them to wait indefinitely for someone to call notify(). But there are no other calls to … Read more

[Solved] Find smallest even from array. and also average of even and odd numbers?

Try this. package lesson5; import java.util.Scanner; public class task3 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int [] masarray = new int [10]; int a,b,c,d,f,g,j,m,n,l; int flag_even =0; int min_even = 0; float sum_even=0; float sum_odd=0; int total_even=0; int total_odd=0; System.out.println(“input first number of array”); a=sc.nextInt(); masarray [0]= a; System.out.println(“input … Read more

[Solved] simple string decoding using java [duplicate]

static Map<String, String> map = new HashMap<>(); static { for (int i = 1; i < 26; ++i) map.put(Integer.toString(i), Character.toString((char)(‘A’ + i – 1))); } static void decode(String decoded, String encoded, List<String> result) { int len = encoded.length(); if (len == 0) result.add(decoded); else for (int i = 1, max = Math.min(2, len); i <= … Read more

[Solved] Trying to add an onItemSelectedListener to a spinner

Here is how spinner can be used // Reference the spinner Spinner spinner = (Spinner) findViewById(R.id.spinner); // Set spinner onItemClickListener spinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { Toast.makeText(secActivity.this, “You have clicked”, Toast.LENGTH_SHORT).show(); } }); 2 solved Trying to add an onItemSelectedListener to a spinner