• 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
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

check return type of method  RSS feed

 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hiiiii i am new to java i have one boolean function where i have to check return type of method in if condition how can i do that please help me
 
Ranch Hand
Posts: 129
Firefox Browser Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

amrut sabade wrote:hiiiii i am new to java i have one boolean function where i have to check return type of method in if condition how can i do that please help me



please make it clear so that some one can help you try giving that code snippet and ask where you want exact help ..
 
amrut sabade
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi i have this method

so how can i determine that this method returns true in if condition?
 
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you elaborate what you are trying to accomplish?

There could be a lot of catches in what you are asking & we can lead you to the solution(not provide it).

Please use the code tag if you are trying to paste the code.


 
Ranch Hand
Posts: 255
2
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so, you want to call a method inside if statement ?
 
amrut sabade
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sure iam trying to access a field of form using bean n chech where name is less than 3 characters if it is less than that return false...... check this condition in a actionclass n accordingly redirect the page.. so i just need how the return type of the method can be checked so as to redirect page
 
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

amrut sabade wrote:hi i have this method

so how can i determine that this method returns true in if condition?



Well, the easiest way is to call the method and see what it returns. Any reason you can't do that?
 
Avishkar Nikale
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suggest you start by reading a good book on Java to get hold on
language constructs.

This is very trivial & once you go through a good book you can write this code.

For your information the if condition accepts any boolean value or
call to a boolean function inside the round-brackets.

Hope this will lead you to the solution.
 
amrut sabade
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ya i want to call method inside the if() and check where it is true...
 
Ranch Hand
Posts: 276
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

amrut sabade wrote:so how can i determine that this method returns true in if condition?


Just call that method by passing some argument, you'll get to know what this method returns.

Is this what you want? I'm not sure of my interpretation though..
 
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just for clarity, you're not checking the return type of the method, you're checking the returned *value*. They mean quite different things.
 
Marshal
Posts: 60806
190
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at the code conventions; there is something very similar to what you want in ยง10.5.2.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!