Win a copy of Modern frontends with htmx this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Ignoring of blanks

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 1776
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 (
 
Ranch Hand
Posts: 93
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
=)
 
Marshal
Posts: 79082
376
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote: particularly the second.


thanks!!
I will well write
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic