Programming Tutorials Browser Tutorials Articles Struts Tutorials Hibernate Tutorials

  Tutorial: Exercise - Pad Left

Write a method to return a string which is the parameter with add extra blanks to the left end to make it length width.

Tutorial Details:

Write a method to return a string which is the parameter with add extra blanks to the left end to make it length width. If the string is already width characters or longer, no padding should be performed.

Hint
The simplest, but not the most efficient, is to loop adding blanks to the left until the string is long enough. The reason this isn't efficient for a large amount of padding is that each time thru the loop creates a new String object.


 

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

Read Tutorial at: Click here to view the tutorial

Rate Tutorial:
Exercise - Pad Left

View Tutorial:
Exercise - Pad Left

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
 
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
 
Cache in on faster, more reliable JSPs - JavaWorld May 2001
Cache in on faster, more reliable JSPs - JavaWorld May 2001
 
Add ghosted drag images to your JTrees - JavaWorld Tips
Add ghosted drag images to your JTrees - JavaWorld Tips
 
Flex your grid layout
Flex your grid layout
 
roots of constants classes
roots of constants classes
 
Juggling JOGL
This article introduces the concepts in JOGL, the Java bindings to OpenGL, that are applicable to 2D gaming. We start with the handling of coordinate spaces and how they\'re scaled from the OpenGL world to the screen. Then we integrated JOGL\'s built-in A
 
An Intelligent Nim Computer Game, Part 1
An Intelligent Nim Computer Game, Part 1 In this article, you learn how to play Nim, and discover tools for creating an intelligent computer player. In the next article, you apply those tools to the creation of that player, while building console and G
 
Doclipse, a Javadoc tag plug-in for Eclipse
Doclipse A JavaDoc Tag Plug-in for Eclipse
 
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
 
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
 
fetchExc - fetches mail with webDAV from Exchange 2000/2003 servers
FethExc is java utilily which retrieves mail from your MS Exchange (2000/2003) inbox and forwards it to SMTP server of your choice. FetchExc uses webDAV (OWA) to retrieve mail either over http or https.
 
Client Side Address Validation in Struts
Client Side Address Validation in Struts Client Side Address Validation in Struts In this lesson we will create JSP page for entering the address and use the functionality provided by Validator Framework to validate the user data on the browser.
 
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.
 
Sun Software Express Program Revamps
The Software Express Program, which offers previews of the Solaris OS under development, is in transition due to the recent release of the Solaris 10 OS.
 
Site navigation
 

 

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

Copyright © 2006. All rights reserved.