[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Need help writing a simple code in Java. Basically what the code

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 13
Thread images: 1

File: java-logo.jpg (36KB, 651x400px) Image search: [Google]
java-logo.jpg
36KB, 651x400px
Need help writing a simple code in Java.
Basically what the code should do is analyze a string and output the first and second word. By word I mean a string of adiacent alphabetic letters.
For example in the string " Hello, my name is Luca ", it shuld return Hello and my.
In the string " Hel!lo" it should return Hel and lo.
The challenge consists in not using nor loops nor if conditions, and the code must include .indexOf() and .substring()
>>
Anyone?
>>
>>>/r/homeworkhelp
>>
>>55139415
thanks m8
>>
if you can't do this, you should just stop while you're behind.

literally use google or go to the programming general thread
>>
>>55139305
Use char
>>
YOU HAVE TO GO STACK
>>
Just use .split(" ") or something.
There are much better sources out there that have answers to these kind of homework questions
>>
Don't even use google. Just fucking think it through. You don't even need to use the string functions for it. Do it like an array. Iterate over the string store the sequence of alphabetical characters. The first one that doesn't satisfy that condition is where you stop for your first "word" then continue from where you left off and store the next "word".

This is a naive solution, but whatever. You'll need to handle cases like if the first character is not alphabetical or when you have multiple non alphabeticals between words. But those are easy to handle.
>>
>>55139678
>The first one that doesn't satisfy that condition
>condition

no loops or conditions
>>
>>55139305
Google how to regex
>>
>>55139763
Oh fuck you have to use the string libraries and no looping, didn't read the full post. Then yeah probably can't help, read the oracle API for strings (I don't know Java well) and split the string up into subparts, based on the restrictions for words. If I remember correctly the string API has almost everything you need to avoid iterating over it yourself.
>>
>>55139840
This is the easiest way
Thread posts: 13
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.