Enhanced FOR loops in C++

In C++11, if your compiler supports it, yes it is. It’s called range-based for. It works for C style arrays and any type that has functions begin() and end() that return iterators. Example:

Censored Words Condition

The best solution would be to use a regex with word boundary. if(myString.matches(“.*?\\bdarn\\b.*?”)) This prevents you from matching sdarnsas a rude word. 🙂 demo here

What’s the advantage of load() vs get() in Hibernate?

Whats the advantage of load() vs get() in Hibernate? load() get() Only use load() method if you are sure that the object exists. If you are not sure that the object exist, then use one of get() methods. load() method will throw an exception if the unique id is not found in the database. get() method will return null if the … Read more

Java file outside of source root intelliJ

If you do an ‘import from git’, IntelliJ doesn’t import the project structure from maven (or gradle) automatically. One way to do this afterwards is to right-click on the pom.xml file in the root directory, and select ‘Add as maven project’. Then the folders will be marked correctly, and dependent libraries will be imported. There … Read more

Java split string to array

This behavior is explicitly documented in String.split(String regex) (emphasis mine): This method works as if by invoking the two-argument split method with the given expression and a limit argument of zero. Trailing empty strings are therefore not included in the resulting array. If you want those trailing empty strings included, you need to use String.split(String regex, int limit) with a negative value for … Read more

What is the significance of log4j.rootLogger property in log4j.properties file? What happens if I don’t use this property?

Samudra Gupta explains in his book1: The Logger object is the main object that an application developer uses to log any message. The Logger objects acting within a particular instance of an application follow a parent-child hierarchy. If you have the following configuration: This is how the logger hierarchy could end up looking:2 Samudra Gupta continues to explain: At the … Read more

This view is not constrained

To quickly resolve this, use this very helpful shortcut in Android Studio: Right-click widget-in-question > Constraint Layout > Infer Constraints: Thereafter, you can tweak the constraints as described here: https://stackoverflow.com/a/37960888/5556250 Update This is not correct for the Android Studio v3 and up. As per @purpleladydragons’s comment: “Constraint Layout” is not in the dropdown menu. Use the magic wand icon … Read more

SSL peer shut down incorrectly in Java

That is a problem of security protocol. I am using TLSv1 but the host accept only TLSv1.1 and TLSv1.2 then I changed the protocol in Java with the instruction below: System.setProperty(“https.protocols”, “TLSv1.1”);

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)