1. Check If Java is Already Installed java -version javac –version 2. Download Java Go to download page. 3. Install Java from downloaded .exe file 4. Configure Environment Variable Start Menu -> Search -> Edit System Environment Variables -> Environment Variable -> NEW -> Enter "JAVA_HOME" and "PATH_TO_JDK" 5. Test in Command Prompt echo %JAVA_HOME% …
Solve Problem: Microsoft Spotlight Lock Screen Can’t Update Automatically in Windows11
1. Start Menu -> Computer Management -> Service and Application -> Service 2. Find "Background Intelligence Transfer Service" -> Property -> Set Automatic 3. Personalize -> Lock Screen -> Set "Picture" 4. Navigate to target directory in file navigator %LOCALAPPDATA%\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\Settings 5. Delete Settings.data 6. Go back to parent path -> LocalState folder-> Assets folder -> …
Permutation – Java
What is the algorithm if we want to get the whole permutation combinations from a given array in java? I will introduce the algorithm in my own word: We take [a, b, c] as an example. We initialize an variable named as "cur", which means the current index we are concerning about how many different …
HttpSession
What is HttpSession Server will create a independent HttpSession for each register user. What does HttpSeesion do When user first time visit the Servlet, the server will create a independent Session for user. And generate an Session ID. This Session ID could be stored in explorer’s cookie. When user visit this Servlet next time, the …
Programming to Interface
Coding to interfaces is a technique to write classes based on an interface; interface that defines what the behavior of the object should be. It involves creating an interface first, defining its methods and then creating the actual class with the implementation. At first, it looks like over coding, but, there are two main reasons …
@RequestMapping, @GetMapping and @PostMapping in Spring
@RequestMapping Originally, Spring had only @RequestMapping annotation for mapping all the incoming HTTP request URLs to the corresponding controller methods. @RequestMapping(value = "/users", method = RequestMethod.GET) public Users getUsers() { } @RequestMapping(value = "/users", method = RequestMethod.POST) public User createUser(User user) { } @RequestMapping(value = "/users/{id}", method = RequestMethod.GET) public User getUser(@PathVariable("id") String id) { …
Continue reading “@RequestMapping, @GetMapping and @PostMapping in Spring”
The Spring @Controller and @RestController Annotations
In Spring Boot, the controller class is responsible for processing incoming REST API requests, preparing a model, and returning the view to be rendered as a response. The controller classes in Spring are annotated either by the @Controller or the @RestController annotation. These mark controller classes as a request handler to allow Spring to recognize …
Continue reading “The Spring @Controller and @RestController Annotations”
How to reverse String in java
Use the code below: // conversion from String object to StringBuffer StringBuffer sbr = new StringBuffer(str); // To reverse the string sbr.reverse();
Error: Web server failed to start. Port **** was already in use.
Use the code to kill this port: npx kill-port ****
How to convert Array to List
Plain Java public void givenUsingCoreJava_whenArrayConvertedToList_thenCorrect() { Integer[] sourceArray = { 0, 1, 2, 3, 4, 5 }; List<Integer> targetList = Arrays.asList(sourceArray); } Commons Collection public void givenUsingCommonsCollections_whenArrayConvertedToList_thenCorrect() { Integer[] sourceArray = { 0, 1, 2, 3, 4, 5 }; List<Integer> targetList = new ArrayList<>(6); CollectionUtils.addAll(targetList, sourceArray); } Guava public void givenUsingGuava_whenListConvertedToArray_thenCorrect() { List<Integer> sourceList = …