Programming Tutorials Browser Tutorials Articles Struts Tutorials Hibernate Tutorials

  Tutorial: Exercise - Trim Right

Write a method that returns a string with all trailing blanks from the right end of its string parameter.

Tutorial Details:

Problem
Write a method that returns a string with all trailing blanks from the right end of its string parameter. This should work even with strings with no characters, no whitespace, or no non-whitespace.

Hint
Loop from the right end, using Character.isWhitespace() to test each character. When you find find something that isn't whitespace, return everything up to and including that character.


 

Rate Tutorial:
http://www.roseindia.net/java/java-tips/data/strings/q-pr-string-using-loops/q-pr-trimright.shtml

Read Tutorial at: Click here to view the tutorial

Rate Tutorial:
Exercise - Trim Right

View Tutorial:
Exercise - Trim Right

Related Tutorials:

The battle of the container frameworks: which should you use? - JavaWorld - January 1999
The battle of the container frameworks: which should you use? - JavaWorld - January 1999
 
Java Tip 71: Use dynamic messaging in Java - JavaWorld - April 1999
Java Tip 71: Use dynamic messaging in Java - JavaWorld - April 1999
 
Design networked applications in RMI using the Adapter design pattern
Design networked applications in RMI using the Adapter design pattern
 
Enhance your Java application with Java Native Interface (JNI)
Enhance your Java application with Java Native Interface (JNI)
 
Speed up listener notification - JavaWorld February 2000
Speed up listener notification - JavaWorld February 2000
 
Create dynamic images in Java servlets - JavaWorld May 2000
Create dynamic images in Java servlets - JavaWorld May 2000
 
Flex your grid layout
Flex your grid layout
 
Publish
Publish event-driven Web content with JSP custom tags
 
A recipe for cookie management
A recipe for cookie management
 
Eclipse casts shadows
Eclipse casts shadows
 
roots of constants classes
roots of constants classes
 
An no-nonsense guide to Semantic Web specs for XML people (Part I)
A No-Nonsense Guide to Semantic Web Specs for XML People The Semantic Web has a serious problem: the XML people don't understand it. They think it's an utterly complex way to write metadata that you can do with simple namespaces. The two worlds (despit
 
From Writing Programs to Creating Compilers
From Writing Programs to Creating Compilers In this article we build a simple compiler that augments Java with tasks (independent blocks of code that execute in parallel), thus creating a new language called AJ that well supports the programming of syste
 
Portlet Community
Portlet Community If J2EE based portals, JSR 168 or WSRP mean anything to you, you have come to the right place.
 
Enhance looping in Java 5.0 with for/in
The for/in loop -- often called either enhanced for or foreach is largely a convenience feature in Java 5.0. It doesn\\'t really offer any new functionality, but certainly makes several routine coding tasks simpler.
 
The Apache Derby Project
Derby is an effort undergoing incubation at the Apache Software Foundation. Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision-making process have stabilised in a ma
 
J2J - Java to JavaScript integration.
It is a development tool lets you to integrate Java classes and JavaScript within your HTML pages. The main idea behind this product is how to call methods of Java classes right from JavaScript functions.
 
Creating EJB clients using the Eclipse Rich Client Platform
This article shows how to build a sample EJB client using the Eclipse Rich Client Platform (RCP), which has become increasingly popularity due to its extensible nature.
 
Simredo 4.0 - Java Unicode Editor
Simredo is a free Java Unicode editor.
 
one-jar
One-JAR is a simple solution to a vexing problem in Java: how to distribute an application as a single jar-file, when it depends on multiple other jar-files. One-JAR uses a custom classloader to discover library jar files inside the main jar.
 
Site navigation
 

 

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2006. All rights reserved.