n/a
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
n/a
Last edited by SaltSlasher; June 24th, 2024 at 03:12 AM.
Are you trying to get the first letter and the last letter from a String?I then need to print out just the "1" and on a separate line the "5".
Look at using the String class's substring method. It will allow you to get any character in a String.
If you are working with an int value you will need to use division (/) and modulus/remainder(% ) operators.
If you're not sure how they work, write a small simple program, use one of the operators and print out the results. Do it for many different values to see what happens. For exampl:
int x = 10;
System.out.println("div by 4=" + (x/4)); // show results when divided by 4
System.out.println("rem for 4" + (x%4)) ; // show results with modulus operator
Change the 4 and the 10 to many different values
Have you figured it out now?
Glad you got it working.
In the future Please wrap your code with[code=java]<YOUR CODE HERE>[/code] to get highlighting
Next step in posting code is to properly indent. The code in each nesting level of {} should be indented.
Something like this: