{"id":1232,"date":"2026-09-03T15:00:00","date_gmt":"2026-09-03T09:30:00","guid":{"rendered":"https:\/\/swapnilzambare.com\/blog\/apex-methods-parameters-return-types\/"},"modified":"2026-09-03T15:00:00","modified_gmt":"2026-09-03T09:30:00","slug":"apex-methods-parameters-return-types","status":"publish","type":"post","link":"https:\/\/swapnilzambare.com\/blog\/apex-methods-parameters-return-types\/","title":{"rendered":"Apex Methods, Parameters and Return Types Explained"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Apex Methods give a name to a block of code that does one job. For example, one method might calculate a fee, and another might check a date. So instead of writing the same logic in five places, you write it once. Then you call it whenever you need it. This keeps your code short, easy to test and easy to change.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You have already used methods without thinking much about them. In <a href=\"https:\/\/swapnilzambare.com\/blog\/what-is-salesforce-apex-first-class\/\">your first Apex class<\/a>, <code>welcome<\/code> and <code>feeAfterDiscount<\/code> were methods. In the post on <a href=\"https:\/\/swapnilzambare.com\/blog\/apex-collections-list-set-map\/\">Apex collections<\/a>, <code>add<\/code>, <code>get<\/code> and <code>size<\/code> were methods too. Now we will look at how to design and write your own, step by step. The examples build on <a href=\"https:\/\/swapnilzambare.com\/blog\/apex-operators-expressions\/\">Apex operators<\/a> as well.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What Are Apex Methods?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A method is a set of statements grouped under a name inside a class. It can take input values, called parameters, and it can send back one result, called the return value. You run a method by calling its name.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Think of a coffee machine. You put in coffee beans and water, which are the parameters. You press one button, which is the method call. A cup of coffee comes out, which is the return value. You do not need to know how the machine works inside. You only need to know what to put in and what you get back.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why Apex Methods Matter<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Well-designed Apex Methods make code easy to live with. Poor ones create code that nobody wants to touch. Here is why they matter so much.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Reuse.<\/strong> Write the fee rule once and call it from a trigger, a flow and a component.<\/li>\n\n<li><strong>Readability.<\/strong> A call like <code>isCourseFull(c)<\/code> explains itself.<\/li>\n\n<li><strong>Testing.<\/strong> Small methods are easy to test one at a time.<\/li>\n\n<li><strong>Safer changes.<\/strong> When the tax rate changes, you edit one method, not ten files.<\/li>\n\n<li><strong>Teamwork.<\/strong> Teammates can use your method without reading every line inside it.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">How Apex Methods Work<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">When code calls a method, Apex jumps into the method body. It copies the values you passed into the parameters. Then it runs the statements one by one. When it reaches <code>return<\/code>, it sends the result back to the caller and continues from where it left off.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><a href=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/10\/apex-methods-parameters-return-types-diagram-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/10\/apex-methods-parameters-return-types-diagram-1-1024x640.png\" alt=\"Apex Methods diagram showing the signature, parameters, body and return\" class=\"wp-image-1230\" srcset=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/10\/apex-methods-parameters-return-types-diagram-1-1024x640.png 1024w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/10\/apex-methods-parameters-return-types-diagram-1-300x188.png 300w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/10\/apex-methods-parameters-return-types-diagram-1-768x480.png 768w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/10\/apex-methods-parameters-return-types-diagram-1-1536x960.png 1536w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/10\/apex-methods-parameters-return-types-diagram-1-2048x1280.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">The four parts of an Apex method.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">So a method call is like a short detour. The program leaves the main road, does the job inside the method, and then comes back with the result.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Parts of Apex Methods<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">All Apex Methods have the same set of parts, written in a fixed order. The table below breaks down a real method from Bright Path Tutors.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Part<\/th><th>Example<\/th><th>What it means<\/th><\/tr><\/thead><tbody><tr><td>Access modifier<\/td><td>public<\/td><td>Who can call this method<\/td><\/tr><tr><td>static keyword<\/td><td>static<\/td><td>Call it on the class, no object needed<\/td><\/tr><tr><td>Return type<\/td><td>Decimal<\/td><td>The type of value it sends back<\/td><\/tr><tr><td>Method name<\/td><td>applyDiscount<\/td><td>What you call it by<\/td><\/tr><tr><td>Parameters<\/td><td>(Decimal fee, Integer percent)<\/td><td>Inputs, each with a type and name<\/td><\/tr><tr><td>Body<\/td><td>{ &#8230; }<\/td><td>The statements that do the work<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Here is that full method written out.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public static Decimal applyDiscount(Decimal fee, Integer percent) {\n    Decimal discount = fee * percent \/ 100;\n    return fee - discount;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The first line is the method signature. It says this method is public, static, returns a Decimal, and needs a fee and a percentage. The body works out the discount, and <code>return<\/code> sends back the final fee.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Access Modifiers<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The modifier controls who can call the method. <code>public<\/code> means any code in your org can call it, while <code>private<\/code> means only code in the same class can. We will cover all four modifiers in a later post in this level.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Return Types and void<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Every method must declare a return type. If the method sends nothing back, use <code>void<\/code>. A <code>void<\/code> method does work, such as logging or updating a record, but returns no value.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Parameters<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Parameters are the inputs. You list them inside the brackets, each with a type and a name, separated by commas. A method can have zero parameters, written as empty brackets <code>()<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Return Value vs void<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The table below compares methods that return a value with methods that return nothing.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Feature<\/th><th>Method with a return type<\/th><th>void method<\/th><\/tr><\/thead><tbody><tr><td>Sends back a value<\/td><td>Yes<\/td><td>No<\/td><\/tr><tr><td>Must use return with a value<\/td><td>Yes, on every path<\/td><td>No, plain return is optional<\/td><\/tr><tr><td>Can be used in an expression<\/td><td>Yes, like fee = calc()<\/td><td>No<\/td><\/tr><tr><td>Typical job<\/td><td>Calculate, check, build<\/td><td>Save, log, send<\/td><\/tr><tr><td>Example<\/td><td>Decimal finalFee(Decimal fee)<\/td><td>void logCourse(Course__c c)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">When to use which depends on the job. Use a return type when the caller needs an answer, and use <code>void<\/code> when the method just performs an action.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><a href=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/10\/apex-methods-parameters-return-types-diagram-2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/10\/apex-methods-parameters-return-types-diagram-2-1024x640.png\" alt=\"Apex Methods diagram comparing methods that return a value with void methods\" class=\"wp-image-1231\" srcset=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/10\/apex-methods-parameters-return-types-diagram-2-1024x640.png 1024w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/10\/apex-methods-parameters-return-types-diagram-2-300x188.png 300w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/10\/apex-methods-parameters-return-types-diagram-2-768x480.png 768w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/10\/apex-methods-parameters-return-types-diagram-2-1536x960.png 1536w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/10\/apex-methods-parameters-return-types-diagram-2-2048x1280.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Methods that return a value vs void methods.<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">A Real Apex Methods Example<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s build a <code>FeeCalculator<\/code> class with four Apex Methods for Bright Path Tutors. It applies a discount, adds 18% tax and returns the final fee. It also has a <code>void<\/code> method that prints a fee summary.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public with sharing class FeeCalculator {\n\n    private static final Decimal TAX_RATE = 18;\n\n    public static Decimal applyDiscount(Decimal fee, Integer percent) {\n        return fee - (fee * percent \/ 100);\n    }\n\n    public static Decimal addTax(Decimal amount) {\n        return amount + (amount * TAX_RATE \/ 100);\n    }\n\n    public static Decimal finalFee(Decimal fee, Integer percent) {\n        Decimal discounted = applyDiscount(fee, percent);\n        return addTax(discounted).setScale(2);\n    }\n\n    public static void printSummary(String courseName, Decimal fee, Integer percent) {\n        System.debug(courseName + ': ' + finalFee(fee, percent));\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Each method has one clear job. <code>finalFee<\/code> reuses the other two methods instead of repeating their maths. The <code>setScale(2)<\/code> call rounds the result to two decimal places. Finally, <code>printSummary<\/code> is <code>void<\/code>, because it only writes to the log.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now call it from anonymous Apex.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Decimal price = FeeCalculator.finalFee(6000, 10);\nSystem.debug('Final fee: ' + price);\n\nFeeCalculator.printSummary('LWC Basics', 8000, 0);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The first call stores the result in a variable. The second call is a <code>void<\/code> method, so we do not store anything. So the log shows these two lines.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>USER_DEBUG [2]|DEBUG|Final fee: 6372.00\nUSER_DEBUG [19]|DEBUG|LWC Basics: 9440.00<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Method Overloading<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Apex lets two methods share the same name if their parameters differ. Developers call this overloading. It is handy when a method has a common default.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ No discount given, so use 0\npublic static Decimal finalFee(Decimal fee) {\n    return finalFee(fee, 0);\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Add this to <code>FeeCalculator<\/code>, and now you can call <code>finalFee(6000)<\/code> or <code>finalFee(6000, 10)<\/code>. Apex picks the right version by looking at the number and types of the values you pass.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How Apex Passes Parameters<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This part confuses many beginners, so let&#8217;s go slowly. Apex passes every parameter by value. For simple types like Integer or String, the method gets a copy. So changing the parameter inside the method does not change the caller&#8217;s variable.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For objects and records, the copy is a copy of the reference. Both the caller and the method point to the same record. As a result, if a method changes a field on a record, the caller sees that change.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public static void markOnline(Course__c c) {\n    c.Is_Online__c = true; \/\/ the caller's record changes too\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you call <code>markOnline(myCourse)<\/code>, then <code>myCourse.Is_Online__c<\/code> is now true. This behaviour is useful in triggers, where helper methods often update records passed in from <code>Trigger.new<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Calling Apex Methods<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">How you call a method depends on where it lives. For a static method, you write the class name, a dot and the method name, such as <code>FeeCalculator.finalFee(6000, 10)<\/code>. Inside the same class, you can drop the class name and just write <code>finalFee(6000, 10)<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Instance methods work a little differently. First, you create an object with <code>new<\/code>, and then you call the method on that object. We will learn this in the next post on classes and objects. Later, we compare both styles in the post on static and instance members.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Flows and components can also call Apex Methods from outside Apex. A flow can call a method marked <code>@InvocableMethod<\/code>. A Lightning Web Component can call a method marked <code>@AuraEnabled<\/code>. These are just normal Apex Methods with an extra label, so everything you learn here still applies.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Keep Apex Methods Small<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A simple test helps here. Try to describe what the method does in one short sentence without using the word &#8220;and&#8221;. If you cannot, the method probably does too much.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, &#8220;works out the final fee&#8221; is one job. However, &#8220;works out the fee and saves the course and emails the student&#8221; is three jobs. Split that into three Apex Methods, and call them one after another from a small parent method. Each piece is now easy to read, test and reuse.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Naming Apex Methods Well<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Names matter more than most beginners think. A good method name starts with a verb and says what it does. For example, <code>calculateFee<\/code>, <code>isCourseFull<\/code> and <code>sendWelcomeEmail<\/code> all read clearly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Methods that return a Boolean often start with <code>is<\/code>, <code>has<\/code> or <code>can<\/code>. So <code>hasSeatsLeft(c)<\/code> reads almost like a question. Avoid vague names like <code>doStuff<\/code> or <code>process2<\/code>, because nobody will know what they do next month.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common Mistakes with Apex Methods<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Missing a <code>return<\/code> on some path. Apex refuses to compile if any path can end without returning a value.<\/li>\n\n<li>Writing one giant method that does everything. Split it into small methods with one job each.<\/li>\n\n<li>Expecting a changed Integer parameter to update the caller. Primitives are copies, so return the new value instead.<\/li>\n\n<li>Calling an instance method as if it were static. Use <code>ClassName.method()<\/code> only for static methods.<\/li>\n\n<li>Putting SOQL inside a method that runs in a loop. The query still runs once per call.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Best Practices for Apex Methods<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Give each method one job and a name that starts with a verb.<\/li>\n\n<li>Keep methods short, ideally under 30 lines, so they fit on one screen.<\/li>\n\n<li>Limit parameters to about four. If you need more, pass an object or a record.<\/li>\n\n<li>Return values instead of changing hidden state, so behaviour is easy to follow.<\/li>\n\n<li>Write a test for each public method as soon as you create it.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Practice Task<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Add a method <code>isPremium(Decimal fee)<\/code> to <code>FeeCalculator<\/code> that returns true when the final fee with tax is above 9000. Then call it for fees of 7000 and 8000. Hint: reuse <code>addTax<\/code> inside the new method.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Official Resources<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/developer.salesforce.com\/docs\/atlas.en-us.apexcode.meta\/apexcode\/apex_classes_defining_methods.htm\" target=\"_blank\" rel=\"noopener noreferrer\">Apex Developer Guide: Class Methods<\/a><\/li>\n\n<li><a href=\"https:\/\/developer.salesforce.com\/docs\/atlas.en-us.apexcode.meta\/apexcode\/apex_classes.htm\" target=\"_blank\" rel=\"noopener noreferrer\">Apex Developer Guide: Classes, Objects and Interfaces<\/a><\/li>\n\n<li><a href=\"https:\/\/trailhead.salesforce.com\/content\/learn\/modules\/apex_database\" target=\"_blank\" rel=\"noopener noreferrer\">Trailhead: Apex Basics and Database<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Quick Recap<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Apex Methods group statements under a name so you can reuse them.<\/li>\n\n<li>A method signature holds the modifier, return type, name and parameters.<\/li>\n\n<li>Use <code>void<\/code> when a method returns nothing.<\/li>\n\n<li>Overloading lets methods share a name with different parameters.<\/li>\n\n<li>Primitives pass as copies, while records pass as shared references.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">What&#8217;s Next?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Methods live inside classes. Next, read <a href=\"https:\/\/swapnilzambare.com\/blog\/apex-classes-and-objects-constructors\/\">Apex classes, objects and constructors<\/a> to learn how to build your own types and create objects from them.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Apex Methods give a name to a block of code that does one job. For example, one method might calculate a fee, and another&hellip;<\/p>\n","protected":false},"author":1,"featured_media":1229,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_swapz_level":"","_swapz_series_part":0,"_swapz_hide_toc":false,"_swapz_hide_featured":false,"_swapz_description":"","footnotes":""},"categories":[8,96],"tags":[98,15,7,97],"swapz_series":[],"class_list":["post-1232","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-salesforce","category-salesforce-developer","tag-apex","tag-beginner","tag-salesforce","tag-salesforce-developer"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Apex Methods, Parameters and Return Types<\/title>\n<meta name=\"description\" content=\"Apex Methods explained for beginners: method parts, parameters, return types, void, overloading and how Apex passes values, with real examples.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/swapnilzambare.com\/blog\/apex-methods-parameters-return-types\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Apex Methods, Parameters and Return Types\" \/>\n<meta property=\"og:description\" content=\"Apex Methods explained for beginners: method parts, parameters, return types, void, overloading and how Apex passes values, with real examples.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/swapnilzambare.com\/blog\/apex-methods-parameters-return-types\/\" \/>\n<meta property=\"og:site_name\" content=\"Swapnil Zambare - Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-03T09:30:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/10\/apex-methods-parameters-return-types-featured.png\" \/>\n\t<meta property=\"og:image:width\" content=\"2400\" \/>\n\t<meta property=\"og:image:height\" content=\"1260\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Swapnil Zambare\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Swapnil Zambare\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-methods-parameters-return-types\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-methods-parameters-return-types\\\/\"},\"author\":{\"name\":\"Swapnil Zambare\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/person\\\/922ac0131aaa7088c78c2cb1700e0c9a\"},\"headline\":\"Apex Methods, Parameters and Return Types Explained\",\"datePublished\":\"2026-09-03T09:30:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-methods-parameters-return-types\\\/\"},\"wordCount\":1582,\"publisher\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-methods-parameters-return-types\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/apex-methods-parameters-return-types-featured.png\",\"keywords\":[\"Apex\",\"Beginner\",\"Salesforce\",\"Salesforce Developer\"],\"articleSection\":[\"Salesforce\",\"Salesforce Developer\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-methods-parameters-return-types\\\/\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-methods-parameters-return-types\\\/\",\"name\":\"Apex Methods, Parameters and Return Types\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-methods-parameters-return-types\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-methods-parameters-return-types\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/apex-methods-parameters-return-types-featured.png\",\"datePublished\":\"2026-09-03T09:30:00+00:00\",\"description\":\"Apex Methods explained for beginners: method parts, parameters, return types, void, overloading and how Apex passes values, with real examples.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-methods-parameters-return-types\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-methods-parameters-return-types\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-methods-parameters-return-types\\\/#primaryimage\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/apex-methods-parameters-return-types-featured.png\",\"contentUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/apex-methods-parameters-return-types-featured.png\",\"width\":2400,\"height\":1260,\"caption\":\"Apex Methods featured image: title card with a method signature\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-methods-parameters-return-types\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Apex Methods, Parameters and Return Types Explained\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/\",\"name\":\"Swapnil Zambare - Blog\",\"description\":\"Salesforce &amp; Tech Guides\",\"publisher\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#organization\",\"name\":\"Swapnil Zambare - Blog\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/site-icon-512.png\",\"contentUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/site-icon-512.png\",\"width\":512,\"height\":512,\"caption\":\"Swapnil Zambare - Blog\"},\"image\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/theSwapnilZambare\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/person\\\/922ac0131aaa7088c78c2cb1700e0c9a\",\"name\":\"Swapnil Zambare\",\"sameAs\":[\"https:\\\/\\\/swapnilzambare.com\\\/blog\"],\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/author\\\/swapnil-zambare\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Apex Methods, Parameters and Return Types","description":"Apex Methods explained for beginners: method parts, parameters, return types, void, overloading and how Apex passes values, with real examples.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/swapnilzambare.com\/blog\/apex-methods-parameters-return-types\/","og_locale":"en_US","og_type":"article","og_title":"Apex Methods, Parameters and Return Types","og_description":"Apex Methods explained for beginners: method parts, parameters, return types, void, overloading and how Apex passes values, with real examples.","og_url":"https:\/\/swapnilzambare.com\/blog\/apex-methods-parameters-return-types\/","og_site_name":"Swapnil Zambare - Blog","article_published_time":"2026-09-03T09:30:00+00:00","og_image":[{"width":2400,"height":1260,"url":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/10\/apex-methods-parameters-return-types-featured.png","type":"image\/png"}],"author":"Swapnil Zambare","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Swapnil Zambare","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/swapnilzambare.com\/blog\/apex-methods-parameters-return-types\/#article","isPartOf":{"@id":"https:\/\/swapnilzambare.com\/blog\/apex-methods-parameters-return-types\/"},"author":{"name":"Swapnil Zambare","@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/person\/922ac0131aaa7088c78c2cb1700e0c9a"},"headline":"Apex Methods, Parameters and Return Types Explained","datePublished":"2026-09-03T09:30:00+00:00","mainEntityOfPage":{"@id":"https:\/\/swapnilzambare.com\/blog\/apex-methods-parameters-return-types\/"},"wordCount":1582,"publisher":{"@id":"https:\/\/swapnilzambare.com\/blog\/#organization"},"image":{"@id":"https:\/\/swapnilzambare.com\/blog\/apex-methods-parameters-return-types\/#primaryimage"},"thumbnailUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/10\/apex-methods-parameters-return-types-featured.png","keywords":["Apex","Beginner","Salesforce","Salesforce Developer"],"articleSection":["Salesforce","Salesforce Developer"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/swapnilzambare.com\/blog\/apex-methods-parameters-return-types\/","url":"https:\/\/swapnilzambare.com\/blog\/apex-methods-parameters-return-types\/","name":"Apex Methods, Parameters and Return Types","isPartOf":{"@id":"https:\/\/swapnilzambare.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/swapnilzambare.com\/blog\/apex-methods-parameters-return-types\/#primaryimage"},"image":{"@id":"https:\/\/swapnilzambare.com\/blog\/apex-methods-parameters-return-types\/#primaryimage"},"thumbnailUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/10\/apex-methods-parameters-return-types-featured.png","datePublished":"2026-09-03T09:30:00+00:00","description":"Apex Methods explained for beginners: method parts, parameters, return types, void, overloading and how Apex passes values, with real examples.","breadcrumb":{"@id":"https:\/\/swapnilzambare.com\/blog\/apex-methods-parameters-return-types\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/swapnilzambare.com\/blog\/apex-methods-parameters-return-types\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/swapnilzambare.com\/blog\/apex-methods-parameters-return-types\/#primaryimage","url":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/10\/apex-methods-parameters-return-types-featured.png","contentUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/10\/apex-methods-parameters-return-types-featured.png","width":2400,"height":1260,"caption":"Apex Methods featured image: title card with a method signature"},{"@type":"BreadcrumbList","@id":"https:\/\/swapnilzambare.com\/blog\/apex-methods-parameters-return-types\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/swapnilzambare.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Apex Methods, Parameters and Return Types Explained"}]},{"@type":"WebSite","@id":"https:\/\/swapnilzambare.com\/blog\/#website","url":"https:\/\/swapnilzambare.com\/blog\/","name":"Swapnil Zambare - Blog","description":"Salesforce &amp; Tech Guides","publisher":{"@id":"https:\/\/swapnilzambare.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/swapnilzambare.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/swapnilzambare.com\/blog\/#organization","name":"Swapnil Zambare - Blog","url":"https:\/\/swapnilzambare.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/09\/site-icon-512.png","contentUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/09\/site-icon-512.png","width":512,"height":512,"caption":"Swapnil Zambare - Blog"},"image":{"@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.linkedin.com\/in\/theSwapnilZambare"]},{"@type":"Person","@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/person\/922ac0131aaa7088c78c2cb1700e0c9a","name":"Swapnil Zambare","sameAs":["https:\/\/swapnilzambare.com\/blog"],"url":"https:\/\/swapnilzambare.com\/blog\/author\/swapnil-zambare\/"}]}},"_links":{"self":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts\/1232","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/comments?post=1232"}],"version-history":[{"count":0,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts\/1232\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/media\/1229"}],"wp:attachment":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/media?parent=1232"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/categories?post=1232"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/tags?post=1232"},{"taxonomy":"swapz_series","embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/swapz_series?post=1232"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}