July 28, 2020

Tic Tac Toe game in java with source code | explained | Java implementation

A Simple tic tac toe game : github url

git clone : https://github.com/consumerfed/game.git

July 21, 2020

Debugging Auto Configuration in spring boot application


Debugging Auto Configuration


There are two approaches you can debug and discover more information about auto 
configuration.

1. Using Spring Boot Actuator

2. Turning on debug logging

You can switch on debug logging by including a simple property value to 
application.properties.

In this example, we are switching on Debug level for all logging from org.springframework 

package (and sub packages).

logging.level.org.springframework: DEBUG

When the application is restarted, you will view an auto configuration report printed in the log.

July 14, 2020

Algorithm to find maximum profit on buying and selling from an array




Class MaximumProfit{

private int maxProfit(int[] prices) {
int profit = 0;
int minimum = 0;
for (int current = 1; current < prices.length; current++) {
int previous = current - 1;
int next = current + 1;
if (prices[previous] > prices[current]) {
minimum = current;
}
if (prices[previous] <= prices[current] && (next == prices.length ||prices[current] > prices[next]  )) {
profit += (prices[current] - prices[minimum]);
}
}
return profit;
}

public static void main(String[] args) {
// int[] a = { 7, 1, 5, 3, 6, 4 };
int[] a = { 1, 2, 3, 4, 5 };
// int []a = {7,6,4,3,1};
// int[] a = { 1, 2, 3, 4, 1 };
System.out.println(new MaximumProfit().maxProfit(a));
}

}

July 07, 2020

Maven : Changing the Version of Java in pom.xml file

Changing the Version of Java


If you wish to change the Java version, you can include a java.version property to pom.xml.

<properties>
    <java.version>1.8</java.version>
</properties>



Facebook comments