Menu

Eclipse shortcuts for Java programming

When you are working with Eclipse IDE to write the java programs, we have too many shortcuts to write the statements in java which Eclipse supports. using these shortcuts you could write your program easy and fast. 
Here I am writing few shortcuts to write java program in Eclipse IDE. Go and try these shortcuts and let us know you have other shortcuts to write and make efficient programming.

Shortcuts commands:

  1. ALT + CTRL + A: to edit and write multiple lines simultaneously  
  2. ALT + Shift + J: Add code Definition
  3. Select a line then ALT + Arrow (Up/Down): to move the code up and down
  4. Shift + Alt + I: to align the code
  5. Shift + mouse hover: to see the method implementation code.
  6. CTRL + O: to see the list of all variables and methods.
  7. CTRL + K: to find matching text within the file.
  8. CTRL + Click on a method name to open the implementation of the method.
  9. Ctrl + space: to open the preference window or template proposal.
  10. You can directly copy and paste your complete code from notepad to eclipse SCR folder, and eclipse will automatically create package and class for that class and paste your code into it. Open notepad > Copy all code from pad > open eclipse > right click on src folder in case if you don't have src folder then right click on project name > select the paste option 
  11. Inline and split variables: select variable then CTRL + 1 and select the option
  12. CTRL + 2, L to assign the value into a local variable
  13. ALT + Shift + M: Select single or multiple lines and move those selected codes in a new method.
  14. Ctrl + Alt-J: to Join more than one lines in a single line
  15. syserr or sysout: to write the complete System.err.println() or  System.out.println() respectively.
  16. Type a string literal "rashid"; select the literal "rashid", then press Ctrl + space, now type sysout/syserr to to pass that string in the argument.


If you face any issue in using these shortcuts then please let us know, we will help you to understand these shorthands.

Java 11 release notes and new features for Java developers

Java 11, released in September 2018, introduced several new features and improvements. Here is a summary of the release notes and some of the key new features in bullet points along with examples:

1. Local-Variable Syntax for Lambda Parameters

   - Allows using `var` as the type of lambda parameters.

   - Example:

// Before Java 11

(String str) -> System.out.println(str);



// Java 11 and later

(var str) -> System.out.println(str);


2. HTTP Client (Standard)

   - The new `java.net.http.HttpClient` API provides a more modern and efficient way to send HTTP requests and receive responses.

   - Example:

HttpClient client = HttpClient.newHttpClient();

HttpRequest request = HttpRequest.newBuilder()

				   .uri(URI.create("https://api.jorvee-java.com/java-sample"))

				   .GET()

				   .build();

HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());

System.out.println(response.body());

3. Enhanced `java.util.stream` API

   - New methods like `takeWhile`, `dropWhile`, `ofNullable` for Stream and Optional.

   - Example:

List<Integer> numbers = List.of(1, 2, 3, 4, 5);
 
// takeWhile
List<Integer> result1 = numbers.stream()
			.takeWhile(n -> n < 4)
			.collect(Collectors.toList()); // Output: [1, 2, 3]


// dropWhile
List<Integer> result2 = numbers.stream()
			.dropWhile(n -> n < 4)
			.collect(Collectors.toList()); // Output: [4, 5]

// ofNullable
Optional<String> optionalValue = Optional.ofNullable(null);

     

4. `var` in Lambda Expression

   - Allows using `var` in lambda expressions, capturing the type from the context.

   - Example:    

     BiFunction<Integer, Integer, Integer> add = (var x, var y) -> x + y;

    

5. Epsilon: A No-Op Garbage Collector

   - Introduces a new garbage collector (`-XX:+UseEpsilonGC`) that does not reclaim memory but allows applications to run without GC overhead.

   - Useful for performance testing or short-lived applications with minimal memory allocation.

6. Nest-Based Access Control

   - Adds support for private interfaces, allowing nested classes to access private members of the enclosing class.

class Outer {

	 private interface InnerInterface {

		 void doSomething();

	 }



	 static class Nested implements InnerInterface {

		 public void doSomething() {

			 System.out.println("Doing something...");

		 }

	 }

}

     

7. Flight Recorder

   - Previously commercial feature, now available for free in OpenJDK.

   - Flight Recorder allows recording and analyzing application events for profiling and debugging purposes.


These are just a few of the new features and improvements introduced in Java 11. The release also includes performance enhancements, security updates, and other improvements. Always ensure to check the complete release notes and documentation for a comprehensive overview of all changes and updates.

Adobe Experience Manager for Content Author