[Solved] Generating a Random String Array

You can do it using nested loop, as you said in the question: public String[] randomArrayString(int length, int numberOfChar) { Random random = new Random(); char[] chars = “abcdefghijklmnopqrstuvwxyz”.toCharArray(); String[] array = new String[length]; String str; for (int i = 0; i < length; i++) { str = “”; for (int j = 0; j … Read more

[Solved] non-void return value in void function table view

Welcome to SO. You are using a function, findObjectsInBackground, that takes a completion closure. The completion closure is another function inside your cellForRowAt function. That function holds onto (captures) the completion closure you pass in and doesn’t call it until the background call is complete. The block you pass in does not return a value. … Read more

[Solved] Change all prices (numbers) with 20% on webpage [closed]

Does the following help: var currentMode = 1; var discount = 0.20; var reverseDiscount = 1/(1-discount); function togglePrices() { var prices = document.getElementsByClassName(“price”); for (var i = 0; i < prices.length; i++) { var individualPrice = prices[i].innerHTML.substring(1); if(currentMode == 1) { individualPrice = parseFloat(individualPrice) * (1-discount); } else { individualPrice = parseFloat(individualPrice) * reverseDiscount; } … Read more

[Solved] How To Connect Two Domain [closed]

You would probably use cURL from php. cURL can do so many things, so you can probably google “php curl upload” or something the get more specific answers. But the key-word you are looking for is probably cURL. Please note that if you are going server-to-server, CORS will not make any difference — CORS only … Read more

[Solved] how can I put 4 equal rectangle in one layout?

This is my solution I state in the comment, as you can see is a nest of LinearLayouts <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:tools=”http://schemas.android.com/tools” android:id=”@+id/activity_main” android:layout_width=”match_parent” android:layout_height=”match_parent” android:weightSum=”100″ android:paddingBottom=”@dimen/activity_vertical_margin” android:paddingLeft=”@dimen/activity_horizontal_margin” android:paddingRight=”@dimen/activity_horizontal_margin” android:paddingTop=”@dimen/activity_vertical_margin” android:orientation=”vertical” tools:context=”net.whatsgift.mitro.weightlayout.MainActivity”> <LinearLayout android:layout_width=”match_parent” android:layout_height=”match_parent” android:layout_weight=”50″ android:orientation=”horizontal” android:weightSum=”100″> <LinearLayout android:layout_width=”match_parent” android:layout_height=”match_parent” android:layout_weight=”50″ android:backgroundTint=”@color/colorAccent”></LinearLayout> <LinearLayout android:layout_width=”match_parent” android:layout_height=”match_parent” android:layout_weight=”50″ android:backgroundTint=”@color/colorPrimary”></LinearLayout> </LinearLayout> <LinearLayout android:layout_width=”match_parent” android:layout_height=”match_parent” android:layout_weight=”50″ … Read more

[Solved] Java Incompatible types: inputstream cannot be converted to scanner

private ArrayList<Student> readFile() throws FileNotFoundException { String fName = “p02-students.txt”; Scanner scan = new Scanner(new File(fName)); ArrayList<Student> studentList = new ArrayList<Student>(); while (scan.hasNext()) { String studentType = scan.next(); if (studentType.equals(“C”)) { studentList.add(readOnCampusStudent(scan)); } else { studentList.add(readOnlineStudent(scan)); } scan.nextLine(); } scan.close(); return studentList; } I didn’t get the error you mentioned earlier, but I was getting … Read more

[Solved] Making an input icon (search icon) responsive [closed]

Try this: .input_with_icon { position: relative; } .input_with_icon .form-control { padding-left: 40px; height: 21px; } .input_with_icon img { position: absolute; top: 5px; bottom: 0; left: 10px; margin: auto; } <div class=”input_with_icon”> <input type=”text” class=”form-control” placeholder=”Search here…”> <img src=”https://stackoverflow.com/questions/59323509/images/search.png”> </div> solved Making an input icon (search icon) responsive [closed]

[Solved] Word count in descending order using java lambdas

This is one way (it does create two streams and does merge the two lines of code): Map<String, Long> map = Arrays.stream(“some text some spaces”.split(” “)) .collect(Collectors.groupingBy(Function.identity(), Collectors.counting())) .entrySet() .stream() .sorted(Map.Entry.<String, Long>comparingByValue().reversed()) .collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue(), (v1, v2) -> v2, LinkedHashMap::new)); System.out.println(map); // This prints: {some=2, spaces=1, text=1} solved Word count in descending … Read more

[Solved] How to change the element of another div by clicking and hovering on an element of a different div

Like people have said there are many ways to do this. One way would be to use JavaScript event listeners. Here’s a quick little demo: let change = document.getElementById(“change”); let hover = document.getElementById(“hover”); hover.addEventListener(“mouseover”, changeColor); hover.addEventListener(“mouseout”, changeColor); function changeColor() { change.classList.toggle(“red”); } div { width: 100px; height: 100px; margin: 2rem; background-color: green; } .red { … Read more