plz anybudy colud tell me how to generate function with return type?

asked 23 Feb '15, 20:47

kapi's gravatar image

kapi
1
accept rate: 0%


You have to write the type, which should be returned, before the name of the function.

function without rerurn:

public static void printHello()
{
System.out.println("Hello");
}

function which return String type:

public static String getHello()
{
String s = "Hello";
return s;
}

function which return int type:

public static int getAge()
{
int age = 30;
return age;
}
link

answered 24 Feb '15, 16:25

vojc's gravatar image

vojc
404
accept rate: 100%

edited 24 Feb '15, 16:28

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×16

Asked: 23 Feb '15, 20:47

Seen: 787 times

Last updated: 24 Feb '15, 16:28