• 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

difference between java Streams and strings

 
Ranch Hand
Posts: 176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the exact difference between java Streams
and Java STrings.
Can someone advise me.
 
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Strings are arrays of characters used to hold data like "Hi I am a string."
A Stream is an i/o class that is used to read and write bytes of data as a continuous sequence of bytes. You can use streams to read and write data from/to files, among other things.
Rob
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A String is not an array of characters per the JLS. However, a String is a sequence of characters. JLS 4.3.3. A String is immutable. The elements of an array can be changed.
 
Bhasker Reddy
Ranch Hand
Posts: 176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks guys for your info
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mariyln,
it's always difficult to know how much detail to use when answering a question, so I tried to keep the answers simple.
You're right that an array of characters is not a string, but that's not what I said.
I said "a string is an array of characters."
From an implementation standpoint, this is correct. Look at the string class...

/** The value is used for character storage. */
private char value[];
Internally it keeps its data in an array of char.
So my statement is technically correct, even though there are significant differences between a String and a char array.
Rob
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rob,
Marilyn is correct a String is not an array of character and an array of character is not a String either. The reason why the character array in class String is made private is that Sun wants the class to be the sole responsible of what happens to it, that is nothing since a String is immutable. Don't see a String as an array of characters or the opposite or else you may get into trouble. An array is mutable while a String is not...
I know that you know that but it is very important that things stay crystal-clear around here...
Also, you were wondering about the level of details in answers. Well, There are never enough details in my opinion... But one thing no one should do is use bad wording to keep it short, that's baaaaaaaad !! use proper wording even if it takes longer to explain.... Saying that a String is an array of character is a bad shortcut...
I'm picky I know Whatever
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic