In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Today Xiaobian to share with you Java beginners easy to confuse the problem what related knowledge points, detailed content, clear logic, I believe most people are still too familiar with this knowledge, so share this article for everyone to refer to, I hope you read this article after some harvest, let's take a look at it.
String class and StringBuffer class
They're all classes that handle strings, but they have one big difference, and that's that String objects store text characters that you can't change.
String, instead, if you want to change it, use the StringBuffer class instead.
eg1:
......
//omit some code
String s1="You are hired! ";
System.out.println(s1.replace ('h ',' f'));//replaces h in string with f
System.out.println(s1);
......
//omit some code
Run results:
You are fired!
You are hired!
Result analysis:
From the results, it is obvious that the value of s1 is not changed, and the first line results are only the replacement of the screen content.
eg2:
......
//omit some code
StringBuffer s2=new StringBuffer("Hello from Java! ");
s2.replace(6,10,"to");
System.out.println(s2);
......
//omit some code
Run results:
Hello to Java!
Result analysis:
Obviously, the value of s2 has changed.
2. bit logic and conditional logic
First of all, in order to distinguish it better from bit logic, I've given what's usually called logic an alias called conditional logic.
They all have their own operators, bit logic operators are:&(AND operation),^(XOR operation),|(OR operation); conditional logical operators are:&&(and
and),||(or).
Bit logic operations are usually performed on two numbers, while conditional logic operations are performed on two conditional expressions
Make. In fact, bitwise logical operators can also implement conditional operations, but there is an important difference at this time: when using bitwise operators, regardless of the two sides of the operator
The conditional expression is not true, it has to be judged by all operations, and the conditional logical operator is different. If you can enter through the operand on the left side,
If they do what they need to do, then it doesn't compute the operand on the right anymore, and that's called a short circuit. Cut the crap! Consider the following example.
eg1:
......
//omit some code
double value=0;
if(value!= 0 && 1/value
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.