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 834935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:44:50+00:00 2026-05-15T04:44:50+00:00

Coming from Java background I am guessing this is expected. I would really love

  • 0

Coming from Java background I am guessing this is expected. I would really love to learn Objective-C and start developing Mac apps, but the syntax is just killing me.

For example:

-(void) setNumerator: (int) n
{
    numerator = n;
}

What is that dash for and why is followed by void in parenthesis? I’ve never seen void in parenthesis in C/C++, Java or C#. Why don’t we have a semicolon after (int) n? But we do have it here:

-(void) setNumerator: (int) n;

And what’s with this alloc, init, release process?

myFraction = [Fraction alloc]; 
myFraction = [myFraction init];
[myFraction release];

And why is it [myFraction release]; and not myFraction = [myFraction release]; ?

And lastly what’s with the @ signs and what’s this implementation equivalent in Java?

@implementation Fraction

@end

I am currently reading Programming in Objective C 2.0 and it’s just so frustrating learning this new syntax for someone in Java background.

UPDATE 1: After reading all these answers and Programming in Objective C 2.0 a little further, it’s all starting to make sense now!

UPDATE 2: Thanks for the great tip “support-multilanguage”. We can combine these two statements into one like so:

myFraction = [Fraction alloc]; 
myFraction = [myFraction init];

Can be reduced to:

myFraction = [[Fraction alloc] init]; 
  • 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-15T04:44:51+00:00Added an answer on May 15, 2026 at 4:44 am

    What is that dash for and why is followed by void in parenthesis?

    The dash - means “instance level” ( which is the default in Java ). When you see a plus sign + it means class level ( same as using static in Java )

    The void in parenthesis is the return type see below.

    Why don’t we have a semicolon after (int) n? But we do have it here:

    -(void) setNumerator: (int) n;
    

    Because that’s the method signature, you can think of it as a interface:

     interface YourClass {
          void setNumerator(int n );// see? semicolon
     }
    

    Same situation.

    Objective-C having roots in C ( actually this is the real C with objects ) needs a header file ( completely removed in Java ) where you define what the functions/methods your class would have.

    The equivalent if such thing would exist in java would be:

    // YourClass.java.h 
    
     interface YourClass {
          void setNumerator(int n );
     }
     // YourClass.java.m
     class YourClass {
          void setNumerator( int n ) {
           this.n = n;
          }
      }
    

    And what’s with this alloc, init, release process?

    myFraction = [Fraction alloc]; 
    myFraction = [myFraction init];
    [myFraction release];
    

    allo-init is the equivalent for new in Java, alloc that’s when you ask for memory for your object, alloc request memory, and init calls the init method, equivalent to the Java class constructor ( btw Ruby does the same behind scenes )

    There’s no equivalent to release in Java because it is garbage collected, in Objective-C you have to release your object.

    BTW, the initialization could also be myFraction = [[Fraction alloc]init];

    And lastly what’s with the @ signs and what’s this implementation equivalent in Java?

     @implementation Fraction
    
     @end
    

    That’s the class definition as I mentioned earlier.

    I am currently reading Programming in Objective C 2.0 and it’s just so frustrating learning this new syntax for someone in Java background.

    Here’s a related answer that will help you to get more familiar with the square brackets:

    Brief history of the “square brackets” is I remember it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 451k
  • Answers 451k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Haven't tried it, but this should work or at least… May 15, 2026 at 8:44 pm
  • Editorial Team
    Editorial Team added an answer Ok, Let's go. You said I am moving to using… May 15, 2026 at 8:44 pm
  • Editorial Team
    Editorial Team added an answer Assuming you're processing one line at a time, you can… May 15, 2026 at 8:44 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.