You can store, access and modify properties available in Velocity class. Velocity has its own default properties available at below path. “org/apache/velocity/runtime/defaults/velocity.properties”
In Apache velocity, There are three main ways to pass data from Java class to VM template. 1. Key and Value mapping 2. Key and Bean/POJO (Object) mapping 3. Key and Inner Map mapping
In velocity template you can import local file using include or you can import other template using parse. #include – Include content of file in template. template engine is not going to rendered included files. #parse – Include template in other template. template engine will rendered this file. Note : #include( “sample.txt”, $sampleFile ) you… Read more
Apache Velocity has if condition like all other programming language. Find below syntax of #if in velocity.
There are three types of comments you can write in Velocity Template.
This tutorial is about #set element in velocity template.
This tutorial is about #foreach loop in velocity. Velocity has #foreach element for looping. Please find below template for more details.
Apache velocity is being used by developer to create dynamic string from predefine template.
Find first and last index of target element from sorted array The best way we can do this with binary search. Big O will be O(2log(n)).
This algorithm to count number of valid substring in given binary string. Valid substrings will be 01, 10, 0011, 1100, 000111, 111000, 00001111, 11110000 …. etc