Stay organized with collections
    
    
      
      Save and categorize content based on your preferences.
    
  
  
    
  
  
  
  
    
    
    
  
  
    
    
    
    Energy
    class Energy : Comparable<Energy!>
    
    Represents a unit of energy. Supported units: calories
    Summary
    
      
        
          | Public methods | 
        
        
          | Int | 
          
            
             Compares this object with the specified object for order. 
           | 
        
        
          | Boolean | 
          
            
             Indicates whether some other object is "equal to" this one. 
           | 
        
        
          | static Energy | 
          
            
             Creates an Energy object with the specified value in calories. 
           | 
        
        
          | Double | 
          
            
             Returns energy in calories 
           | 
        
        
          | Int | 
          
            
             Returns a hash code value for the object. 
           | 
        
        
          | String | 
          
            
            
           | 
        
      
    
    Public methods
    
      compareTo
      
      fun compareTo(other: Energy): Int
      Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
      
        
          
            | Parameters | 
          
          
            o | 
            the object to be compared. | 
          
          
            other | 
            Energy: the object to be compared. This value cannot be null. | 
          
        
      
      
        
          
            | Return | 
          
          
            Int | 
            a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. | 
          
        
      
      
        
          
            | Exceptions | 
          
          
            java.lang.NullPointerException | 
            if the specified object is null | 
          
          
            java.lang.ClassCastException | 
            if the specified object's type prevents it from being compared to this object. | 
          
        
      
     
    
      equals
      
      fun equals(other: Any?): Boolean
      Indicates whether some other object is "equal to" this one.
      
        
          
            | Parameters | 
          
          
            obj | 
            the reference object with which to compare. | 
          
          
            object | 
            the reference object with which to compare. | 
          
        
      
      
        
          
            | Return | 
          
          
            Boolean | 
            true if this object is the same as the object argument; false otherwise. | 
          
        
      
     
    
      fromCalories
      
      static fun fromCalories(value: Double): Energy
      Creates an Energy object with the specified value in calories.
      
        
          
            | Parameters | 
          
          
            value | 
            Double: value to be set as calories. | 
          
        
      
      
        
          
            | Return | 
          
          
            Energy | 
            This value cannot be null. | 
          
        
      
     
    
      getInCalories
      
      fun getInCalories(): Double
      Returns energy in calories
     
    
      hashCode
      
      fun hashCode(): Int
      Returns a hash code value for the object.
      
        
          
            | Return | 
          
          
            Int | 
            a hash code value for this object. | 
          
        
      
     
    
      toString
      
      fun toString(): String
      
        
          
            | Return | 
          
          
            String | 
            a string representation of the object. | 
          
        
      
     
  
  
  
    
  
 
  
    
      
      
    
    
      
    
    
  
       
    
    
      
    
  
  
  Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
  Last updated 2025-02-10 UTC.
  
  
  
    
      [[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[]]