Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How can i rewrite this code into java?

876224Jul 18 2011 — edited Jul 21 2011
How can i rewrite this code into a java that has a return value?
this code is written in vb6
Private Function IsOdd(pintNumberIn) As Boolean
 
    If (pintNumberIn Mod 2) = 0 Then
        IsOdd = False
    Else
        IsOdd = True
    End If
 
End Function    

Private Sub cmdTryIt_Click()
 
          Dim intNumIn  As Integer
          Dim blnNumIsOdd     As Boolean
 
          intNumIn = Val(InputBox("Enter a number:", "IsOdd Test"))
 
          blnNumIsOdd = IsOdd(intNumIn)
 
          If blnNumIsOdd Then
       Print "The number that you entered is odd."
    Else
       Print "The number that you entered is not odd."
    End If
 
 End Sub
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 18 2011
Added on Jul 18 2011
45 comments
621 views