java 8 new features

Hi,

I heard java 8 has bunch of new features. Especially java 8 has different way to deal with strings. Where can i find new features. How the == in java 8 string operation different from earlier versions. please advise
LVL 7
gudii9Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dpearsonCommented:
There was a capability added recently which allows strings to be "de-duplicated" so you only have 1 instance at a time with the same character array:  https://blog.codecentric.de/en/2014/08/string-deduplication-new-feature-java-8-update-20-2/

I guess if you enabled that, you might be able to do string comparisons using == rather than .equals() but that seems risky at best.

There's lots of big changes that came in with Java 8 - but I don't think Strings were really changed.  If you're interested in the new features there's a nice summary here:
http://blog.takipi.com/5-features-in-java-8-that-will-change-how-you-code/

but explaining those features is well beyond the scope of this question :)

Doug
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rrzCommented:
I just saw this
http://java.dzone.com/articles/joining-strings-jdk-8 
I don't know why I haven't heard about these before now.
0
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

zzynxSr. Software engineerCommented:
0
gudii9Author Commented:
https://blog.codecentric.de/en/2014/08/string-deduplication-new-feature-java-8-update-20-2/

With Java 8 Update 20 we now have access to a new feature called String Deduplication, which requires the G1 Garbage Collector and is turned off by default.
how to turn it on. I wonder why it is risk?
0
dpearsonCommented:
The article explains how to turn it on - you need to set a flag when starting Java:
-XX:+UseStringDeduplication

I wonder why it is risk?
Using == for string equality is a risk.  You should use ".equals()" to make sure your code is correct.

String a = "hello" ;
String b = "h" + "ello" ;

// Java says this test may fail (because a and b are not required to point to the same object in memory)
if (a == b) { ... }

// Java says this test will always succeed, because a and b both have the value "hello"
if (a.equals(b)) { ... }

Doug
0
gudii9Author Commented:
The article explains how to turn it on - you need to set a flag when starting Java:
-XX:+UseStringDeduplication

how to turn it on my windows 7 dell laptop. I do have java on it. But i never remember starting java on my laptop. please advise on how to set it on and test
0
dpearsonCommented:
When you run any program written in Java, you have to launch Java to run it.

This usually looks something like:

java -jar myjar.jar

To run it with this String dedup turned on you 'd do:

java -XX:+UseStringDeduplication -jar myjar.jar

If you're using Eclipse to run your Java programs for you, you'd need to figure out where to enter these "JVM parameters" inside Eclipse.  (I don't use Eclipse myself - so I can't help with that one).

Doug
0
gudii9Author Commented:
If you're using Eclipse to run your Java programs for you, you'd need to figure out where to enter these "JVM parameters" inside Eclipse.  (I don't use Eclipse myself - so I can't help with that one).

i am using eclipse amost 99% of the projects, cases. I wonder what you use for development.

I searched on  where to enter these "JVM parameters" inside Eclipse, but could not find any solid answer yet
0
zzynxSr. Software engineerCommented:
>> I searched on  where to enter these "JVM parameters" inside Eclipse, but could not find any solid answer yet
You enter
-XX:+UseStringDeduplication

Open in new window

in the "VM Arguments" text box of the "Arguments" tab (cf. screenshot 2 of this page)

>> I wonder what you use for development.
I use IntelliJ IDEA (not free)
0
gudii9Author Commented:
i will try
0
dpearsonCommented:
I use IntelliJ IDEA (not free)
I also use IntelliJ and while there is a paid version, there is also a free version.  It's called the "Community" edition.

You can get it here:
https://www.jetbrains.com/idea/download/

Doug
0
zzynxSr. Software engineerCommented:
i will try
... and the outcome is?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.