I tried to attach a file to a post by clicking the attachment icon and the file upload dialog did not show. I tried several times with no luck.
Error returning a boolean from method
Hi guys,
I seem to have an issue with a boolean method returining a value. Here is the code excerpt - irrelevant code omitted:
public class StreamsTest {
public static void main(String[] args) {
String[] arr = new String[]{"a", "b", "c"};
//convert array to string with streams
List<String> list = Arrays.stream(arr).collect(Collectors.toList());
isElementInIt(list);
}
static boolean isElementInIt(List<String> list) {
if(list.isEmpty()) {
return false;
}
else {
for (String string : list) {
if (string.contains("a")) {
return true;
}
else {
return false;
}
}
}
}
}
STS says that the isElementInIt method should return a boolean value, but it's already doing that whatever happens, so I'm not too sure why the error. Any idea?
thanks
10 Top Sports APIs for 2021
UPS tracking – make a field be a link to the ups tracking website
I have to take over a php project and I am totally new to php. I have this webpage that displays all packages sent to a customer and I want them to be able to click on the tracking number to do UPS website tracking.
The code:
<?php
$result = mysqli_query($conn, $sql);
if (!$result) {
exit();
} else {
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
echo "<tr>";
echo "<td><strong>";
echo $row['trackingno'];
echo "</td>";
echo "<td>";
echo $row['date_shipped'];
echo "</td>";
echo "<td>";
echo $row['desc_reference2'];
echo "</td>";
echo "<td>";
echo $row['status'];
echo "</td>";
echo "<td>";
echo $row['date_delivered'];
echo "</td>";
echo "</tr>";
}
} else {
echo "There are no Returns matching search!";
}
}
?>
I need the "trackingno" to display the number but be able to clik on it and be a link to
http://wwwapps.ups.com/WebTracking/track?track=yes&trackNums=trackingno
Any suggestions will be highly apprecited.
Sort according to frequency
//With this method, I input a string and return an array that contains a sorted list of characters as per the frequency. Eg: If i input "apple", the out put should be p,a,l,e, How do I do this?
public static ArrayList<Character> characterFreqDist(String statement)
{
char[] Array = statement.toCharArray();
int length = Array.length;
int most_frequent_count = 0;
char most_freq_character = '\0';
char[] Final_Array = new char[length];
ArrayList<Character> Sorted_Array = new ArrayList<Character>();
for(int loop = 0 ; loop<length ; loop++)
{
most_freq_character = '\0';
most_frequent_count = 0;
for(int i = 0; i<length ; i++)
{
char single_character = Array[i] ;
int counter = 0;
for(int j = 0; j<length ; j++)
{
if (single_character == Array[j])
{
counter++;
}
}
if (counter > most_frequent_count)
{
most_frequent_count = counter;
most_freq_character = single_character;
}
}
Sorted_Array.add(most_freq_character);
int index = 0;
for (int k = 0; k < length; k++)
{
if(Array[k] != most_freq_character)
Final_Array[index++] = Array[k];
}
Array = Final_Array.clone();
length = Array.length;
}
return Sorted_Array;
}