Win a copy of Hands On Software Engineering with Python this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

Interface with strictfp  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I need some help to understand strictfp with interface. Hope some can explain using the following code sample, why I can able to use strictfp with Interface not with Interface Methods.

Interface with StrictFp( this compiles fine in Java 1.5)
--------------------------------------------------------
public strictfp interface checkForStrictFp{
public void isItPossible();
}

Interface with StrictFp and strictfp Method( this gives Compile error)
--------------------------------------------------------
public strictfp interface checkForStrictFp{
public strictfp void isItPossible();
}

C:\Tech\MyJava\checkForStrictFp.java:2: modifier strictfp not allowed here
public strictfp void isItPossible();
^
1 error

Tool completed with exit code 1

Anyone know, why I can't use strictfp with Interface method, which is nothing but "abstract" method.

In "abstract" class, if I had method with "strictfp" it compiles successfully.

Code sample:
------------
public abstract strictfp class checkForStrictFpWithAbstract{
public strictfp void isItPossible()
{
System.out.println("Strictfp confirms with IEEE 754");
}
}

Appreciate any help on this.

Thanks very much.
 
Ranch Hand
Posts: 2023
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
9.4 Abstract Method Declarations


Note that a method declared in an interface must not be declared strictfp or native or synchronized, or a compile-time error occurs, because those keywords describe implementation properties rather than interface properties. However, a method declared in an interface may be implemented by a method that is declared strictfp or native or synchronized in a class that implements the interface.

 
karthik panchan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wise Owen

Thanks for your nice explanation.

Karthik
 
Why should I lose weight? They make bigger overalls. And they sure don't make overalls for tiny ads:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!