java - How do I get the first n characters of a string without checking the size or going out of bounds? -


How do I access the n characters before a string in Java without having to type? First check (inline acceptable) or IndexOutOfBoundsException ?

Here's a clean solution:

  string upconverters = s.sstrstring (0, Math.Man (S. Long (), N)); Opinion: While this solution is "clean", I think it is actually  less readable  from a solution that uses   /  other  Clearly, if the reader has not seen this move, then  looks hard  to understand the code. IMO, code is more clear in the  if  /  else  version.  


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -