Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3305558
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:10:59+00:00 2026-05-17T21:10:59+00:00

I know this can be done in Ada but I’m new to Java and

  • 0

I know this can be done in Ada but I’m new to Java and don’t know if I can do this. I would like to make a radian of float subtype from 0 to 2pi. Values outside the range would be considered out of range and through a constraint error. Any help is appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T21:10:59+00:00Added an answer on May 17, 2026 at 9:10 pm

    commons.lang.math.Range just specifies the range constraint. It does not represent a value in that range (which I think is what you want).

    You could create a new class to hold the value and enforce the constraint. Your own program would pass instances of this class around and would thus get the type safety (of having the constraint enforced). When calling other API, you have to revert back to sending and accepting regular double values. You can check the constraint again before accepting return values.

    public class Radian extends Number {
    
         private final double value;
    
         public Radian(double value){
              if (value < 0 || value >= 2 * PI)
                   throw new IllegalArgumentException(value + " is out of range");
              this.value = value;
         }
    
         public double doubleValue(){
             return value;
         }
    
         // ... and other methods in the Number interface
         //   don't forget equals and hashCode and toString
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

OK I would like to know this once and for all, how can I
I know this can be done with mvc2, but is there any way for
I know this can be done with foreign keys but I cannot add them
I know this is probably on the Internet somewhere but I can't find the
I know this maybe a basic question but I just can't seem to find
I know this seams a trivial question, but how can I disable the annoying
Seems so basic, I can't believe I don't know this! I just need a
I know that this is subjective and all, but still, can you provide some
I know I can do this: IDateTimeFactory dtf = MockRepository.GenerateStub<IDateTimeFactory>(); dtf.Now = new DateTime();
I know this can be done and i have seen it done using some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.