- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 270 Articles for Java8
1K+ Views
Following are the best practices while declaring a variable.Variables names should be short or long enough as per the scope. For example, loop counter variable, i is fine whereas employee as a loop variable.Specific words should not be used as equals, compare, data.Use meaningful names which can explain the purpose of the variable. For example cnt Vs counter.Don't use _ to declare a variable name, Use camel casing. For example, employeeName is better than employee_name.Each organization has its own syntax specific standards. Follow those rules to maintain consistency and readability.
361 Views
Yes, from Java 8 onwards, java.util.concurrent.atomic package contains classes which support atomic operations on single variables preventing race conditions or do not face synchronization issues. All classes in the atomic package have get/set methods. Each set method has a happens-before relationship with any subsequent get() method call on the same variable. import java.util.concurrent.atomic.AtomicInteger; class AtomicCounter { private AtomicInteger counter = new AtomicInteger(0); public void increment() { counter.incrementAndGet(); } public void decrement() { counter.decrementAndGet(); } public int value() { return counter.get(); } }
26K+ Views
Class variables also known as static variables are declared with the static keyword in a class, but outside a method, constructor or a block. There would only be one copy of each class variable per class, regardless of how many objects are created from it. Static variables are rarely used other than being declared as constants. Constants are variables that are declared as public/private, final, and static. Constant variables never change from ... Read More
21K+ Views
Instance variables are declared in a class, but outside a method, constructor or any block.When space is allocated for an object in the heap, a slot for each instance variable value is created.Instance variables are created when an object is created with the use of the keyword 'new' and destroyed when the object is destroyed.Instance variables hold values that must be referenced by more than one method, constructor or block, or essential parts of an object's state that must be present throughout the class.Instance variables can be declared at the class level before or after use.Access modifiers can be given ... Read More
1K+ Views
Local VariableLocal variables are declared in methods, constructors, or blocks.Local variables are created when the method, constructor or block is entered and the variable will be destroyed once it exits the method, constructor, or block.Access modifiers cannot be used for local variables.Local variables are visible only within the declared method, constructor, or block.Local variables are implemented at stack level internally.There is no default value for local variables, so local variables should be declared and an initial value should be assigned before the first use.Instance/Member VariableInstance variables are declared in a class, but outside a method, constructor or any block.When a ... Read More
10K+ Views
Member variables are known as instance variables in java.Instance variables are declared in a class, but outside a method, constructor or any block.When space is allocated for an object in the heap, a slot for each instance variable value is created.Instance variables are created when an object is created with the use of the keyword 'new' and destroyed when the object is destroyed.Instance variables hold values that must be referenced by more than one method, constructor or block, or essential parts of an object's state that must be present throughout the class.Instance variables can be declared in a class level ... Read More
2K+ Views
Local variables are declared in methods, constructors, or blocks.Local variables are created when the method, constructor or block is entered and the variable will be destroyed once it exits the method, constructor, or block.Access modifiers cannot be used for local variables.Local variables are visible only within the declared method, constructor, or block.Local variables are implemented at stack level internally.There is no default value for local variables, so local variables should be declared and an initial value should be assigned before the first use.ExampleHere, age is a local variable. This is defined inside pupAge()method and its scope is limited to only ... Read More
3K+ Views
All Java components require names. Names used for classes, variables, and methods are called identifiers. In Java, there are several points to remember about identifiers. They are as follows - Step 1 − All identifiers should begin with a letter (A to Z or a to z), currency character ($) or an underscore (_). Step 2 − After the first character, identifiers can have any combination of characters. Step 3 − A keyword cannot be used as an identifier. Step 4 − Most importantly, identifiers are case sensitive. Step 5 − Examples of legal identifiers: age, $salary, _value, __1_value. Step 6 − Examples of illegal identifiers: 123abc, -salary.
634 Views
Following steps are mostly required to Troubleshoot any problem that occurred in production.As the first step, get the time frame from the user when a particular issue occurred. Get the logs for that particular time period.If logs are very large in size, use grep command to filter out errors.$ grep -o "\w*Exception" error.log | sort -r | uniq -cIt will help to get all the exceptions in error.log sorted in reversed order and give the unique result and with counts.