![]() |
Help with basic java project
Enter a long string: My name is YA123
Enter a substring: name Length of your string:14 Length of your substring:4 Starting position of your substring in string: 4 String before your substring: My String after your substring: is YA123 Enter a position between 0 and 13: 5 The character at position : a Enter a replacement string: username Your new string is: My username is YA123 I need help with this code which probably looks very basic for some of you, but I'm struggling right now. I have up to length of the substring, as shown in the following code. Code:
Scanner keyboard = new Scanner(System.in); |
You are more likely to obtain a response if you post in the correct forum - this is nothing to do with JavaScript (or DOM and JSON scripting). I assume it's Java.
|
Douh! I'm sorry thank you very much.
|
Refrain from re-posting a thread, rather, ask a moderator for it to be moved accordingly (which I did by myself now).
|
Simply use indexOf on string. It accepts a string as well:
PHP Code:
Once you get the index you can use that as a part of the substring method to determine start and end positions (with length's involved). |
| All times are GMT +1. The time now is 11:11 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.