Probably a duplicate but searches haven't turned up any. Maybe I'm just not using the right keywords? IDK. So what they didn't want to see was something like:
char [] myString = "My Funky String".toCharArray();
myString = Arrays.reverse(myString);
//or "".reverse() or StringBuffer().reverse, etc. etc., i.e. no library calls
So I did:
public static void main(String[] args) {
Main app = new Main();
char [] myString = args[0].toCharArray();
int end = myString.length - 1;
for (int i = 0; i < end ; i++,end--) {
app.swap(i, end, myString);
}
System.out.println( new String (myString));
}
public void swap(int posA, int posB, char [] arrayIn) {
char temp = arrayIn[posA];
arrayIn[posA] = arrayIn[posB];
arrayIn[posB] = temp;
}
}
Apparently this also wasn't acceptable. Pretty hardcore for just an SDET job. Oh, BTW, it's a character array because that was the answer when I asked.
I expect I'll get 100 -1's for an assortment of ridiculous and/or petty reasons as per Stupid Operating Procedure now but if that happens I'll just delete the account and discontinue contributing. I'm really getting sick of that silly crap. If that's how Stack wants it, that's how Stack can have it.
Aucun commentaire:
Enregistrer un commentaire