tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Spring > Expression Language > Power Operator

Power Operator 

The Spring Expression Language (SpEL) is a simple and powerful expression language which helps to query and manipulate objects at runtime. The following example shows using power operator.

File Name  :  
com/bethecoder/tutorials/spring3/tests/spel/PowerTest.java 
Author  :  Sudhakar KV
Email  :  [email protected]
   
package com.bethecoder.tutorials.spring3.tests.spel;

import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;

public class PowerTest {

  /**
   @param args
   */
  public static void main(String[] args) {

    ExpressionParser parser = new SpelExpressionParser();
    
    Double value = parser.parseExpression("2^4").getValue(Double.class);
    System.out.println(value);

    value = parser.parseExpression("1.2^2").getValue(Double.class);
    System.out.println(value);
    
    value = parser.parseExpression("0xC ^3").getValue(Double.class);
    System.out.println(value);
    
  }

}
   

It gives the following output,
16.0
1.44
1728.0



 
  


  
bl  br