#JAVA basics need help for school lab
1 messages · Page 1 of 1 (latest)
<@&987246399047479336> please have a look, thanks.
While you are waiting for getting help, here are some tips to improve your experience:
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>.
To check if a string ends in a group of letters or a single letter, you can use the endsWith() method provided by the String class in Java.
Here's an example code snippet to demonstrate how to use endsWith():
public class StringEndsWithExample {
public static void main(String[] args) {
String str = "Hello World";
// Check if the string ends with "ld"
boolean endsWithGroup = str.endsWith("ld");
System.out.println("Ends with group of letters: " + endsWithGroup);
// Check if the string ends with "d"
boolean endsWithSingle = str.endsWith("d");
System.out.println("Ends with single letter: " + endsWithSingle);
}
}
Output:
Ends with group of letters: true
Ends with single letter: true
In this example, we have a string str which is set to "Hello World". We then use the endsWith() method to check if it ends with either "ld" or "d". The result is stored in boolean variables (endsWithGroup and endsWithSingle) and printed out.
its also not going to be hard coded
Try writing the code first
I dont know how thats why im asking
Do you know how to make a String variable called word?
yes
but how do i check if it ends with a single letter or a group of letters
wait im silly
never mind sorry
You use the functions given to you, in the constructor
Can't see
Can you just share the code here? The part where your issue is