#quick question

1 messages · Page 1 of 1 (latest)

ocean flareBOT
#

<@&987246399047479336> please have a look, thanks.

ocean flareBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

#

Here is an AI assisted attempt to answer your question 🤖. Maybe it helps! In any case, a human is on the way 👍. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

#

Without more context or code, it is difficult to determine the exact reason why the black picture does not work while the other one does. However, here are a few potential reasons:

  1. Incorrect file path or name: Make sure that the file path and name for the black picture are correct and accessible by your Java program.

  2. File format issue: Check if the black picture has a valid file format (e.g., JPEG, PNG, etc.) that can be read by your Java program. If it is an unsupported format, you may need to convert it to a compatible format.

  3. Image loading error: There might be an error in loading or displaying the black picture due to issues with the image processing library or code used in your program. Check if there are any error messages or exceptions thrown during image loading.

  4. Image content issue: It is possible that the black picture contains corrupted data or is not properly encoded, causing issues when trying to display it. Try opening the black picture with an image viewer to see if it can be displayed correctly outside of your Java program.

To provide a more specific answer, please provide more details about your code and any error messages you encounter when trying to display the black picture.

hearty fox
#

hey there!

#

you can paste the 2 code snippets easily

#

we aren't compilers or executionners

ocean flareBOT
#

Please use this format for posting code:

```java
// Example java program
int value = 5;
System.out.println(value);
```

Which results in:

// Example java program
int value = 5;
System.out.println(value);

For syntax highlighting, you have to add the name of the language after the three backticks, like ```java. Please make sure to use exactly this format, so no space between the backticks and the language name, and a newline before the code starts. If done right, the syntax highlighting will even be applied to your text as you type, before sending.

ocean palm
#

public int getPriceForHour(int hour) {
int p = -1;
for (int i = 0; i < PriceHour.length; i++) {
if (i == hour) {
p = PriceHour[i]; //
}
}

return p; //

#

so this work as it should do

hearty fox
ocean palm
#

public int getPriceForHour(int hour) {
for (int p : PriceHour) {
if (hour == p) {
return p;
}
}
return -1;
}

#

but this dosen't work

hearty fox
#

show how you are calling both

#

i'd adivse you to try to debug with your IDE

#

so you can see what's happening

ocean palm
#

but it should work same as the first one right

ocean palm
#

oh i think what the issue is

hearty fox
#

the code you mentioned is about a method

#

a method needs to be called with arg

#

show us what you pass in it

ocean palm
#

I wanna do like this instead

#

so im tryin to use for each loop

#

This code should work to retrieve the price for the specified hour from the PriceHour array. It follows a similar logic as the previous implementation, iterating through the array's indices and assigning the corresponding price to the variable p when a match is found. If no match is found, it returns -1

#

but it dosent work when i use for each loop

ocean palm
#

.close