In this section you can learn and practice Aptitude (Questions with Answers) to improve your skills in order to face the interview, competitive examination and various entrance test (CAT, GATE, GRE, MAT, Bank Exam, Railway Exam etc.) with full confidence.
Where can I get aptitude questions and answers with explanation?
XtraStudy provides you lots of fully solved Aptitude questions and answers with explanation. Solved examples with detailed answer description, explanation are given and it would be easy to understand. You can view the solutions for the problems with feel and good user interface.
How to solve Aptitude problems?
You can easily solve all kind of questions based on Aptitude by practicing exercise given in this APTITUDE section.
XtraStudy
What are major topics explained in XtraStudy.com?
Latest Current Affairs
General Knowledge and science
Quantitive Aptitude, C Programming and Verbal Ability are the major topics explained with solved examples and explanation.
Common Admission Test(CAT)
Previous year Questions
Logical Reasoning
Data Interpretation Questions with Solutions - Bar charts, Pie Charts, Line Charts and Table Charts.
Puzzles - Puzzles for Interview, Placement and Competitive Exams
SUDOKU - Sudoku number puzzles
Tea Time Entertainment
Tips and Tricks for Freshers
Shortcuts - shorcut methods to solve problems
Quantitative Aptitude
Ebook Download - Free
Interview Test Papers
Placement Papers
Group Discussion - GD Topics with Answers
HR Interview Questions with Answers
Placement Papers
Quiz, Questions and Answers - PDF, eBook - Download
Xtra Study, xtrastudy, xrastudy, extrastudy, extra study, xtrastudy.in, xtrastudy.com, xtrastudy.net,
extrastudy.com, Xtra Study.com, stra study, strastudy, xtrsatudy, xtarstudy, studyxtra, study study, ncert solutions,
ncert class solutions, cbse solutions
Trim (Remove leading and trailing spaces) a string in Java
Q. Given a string, remove all the leading and trailing spaces from the string and return it.
Examples:
Input : str = " Hello World "
Output : str = "Hello World"
Input : str = " Hey there Joey!!! "
Output : str = "Hey there Joey!!!"
We can eliminate the leading and trailing spaces of a string in Java with the help of trim().
trim() method is defined under the String class of java.lang package.
It does not eliminated the middle spaces of the string.
By calling the trim() method, a new String object is returned.
It doesn’t replace the value of String object. Therefore if we want the access to the new String object, we just need to reassign it to the old String or assign it to a new variable.
How it works? For space character the unicode value is ‘\u0020’. This method checks for this unicode value before and after the string and if it exists then eliminates the spaces(leading and trailing) and returns the string (without leading and trailing spaces).