• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Ignoring of blanks

 
petr pavlovich
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
How to make so that in lines coming and after standing blanks were ignored?
that is
" aaa " = "aaa" ="aaa ''
Name entrance and a way to target files should be set in the form of two parameters of a command line.
in my program
 
John Jai
Rancher
Posts: 1776
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Petr,
I dont understand the program completely. But still is the question is about trimming beginning and trailing white space in string - then use trim() function in String class.
 
petr pavlovich
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi John Jai!
my program: sorting (alphabetically) and outputs the string without repetitions.
 
petr pavlovich
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if the array change"aaa" on " aaa ", the program will not work correctly.


John Jai wrote:Hi Petr,
use trim() function in String class.
how to apply, I do not understand (
 
Ashish Schottky
Ranch Hand
Posts: 93
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@petra: Welcome to Javaranch.
This seems to be a home-work problem.And you have done well.
just use a for-loop and use trim for every string.


 
petr pavlovich
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ashish Schottky wrote:@petra: Welcome to Javaranch.
thanks
Ashish Schottky wrote:
This seems to be a home-work problem.And you have done well.
just use a for-loop and use trim for every string.



Excuse but don't know as to apply your code
The compiler gives out errors
=)
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
. . . and what errors do you get? I can see at least one error. There is a { missing. There might be more; I haven't checked carefully.

You should be writing your code from outside in, not from top to bottom. I would appear to have written that sort of thing before. Look at the links from it, particularly the second.
 
petr pavlovich
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote: particularly the second.

thanks!!
I will well write
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic