Questions tagged [void]

An incomplete type used as syntactic place-holder for the return type of a method/function when no value is returned.

Programming languages derived from C or Algol68, like C++, C#, Java, etc., may define the return type of methods/functions as void when the method/function does not return a value, but simply completes execution.

An example of its use in Java, compared to a non-void method, is:

int nonVoidMethod {
    // do something
    return 0; // return a value to the caller
}

void voidMethod {
    // do something
    return; // no value allowed to be returned from a void method
    // a "return" statement is not required
}

Although void is used as a type, it's an incomplete type:

  • In some languages, such as Java and Algol68, void is only a keyword used as a return type. It is not considered as a valid type in other language constructs.

  • Other languages, like C and C++, consistently define void as a type with an empty set of values. This allows its use for example in compound type constructs (void pointers). But no void objects can be instantiated.

1913 questions
0
votes
4 answers

Set method return type to 'void'. Dont quite understand

Doing a basic android background service app. Do not quite understand why there is a error (MainActivity.java). Error is at btnStart = (Button)findViewById(R.id.btnStart); The quick fix provided was set return type to 'void'. Whereas for…
Joshua
  • 29
  • 1
  • 2
  • 7
0
votes
1 answer

How to make marquee text in tableview

I want to make marquee text in my tableViewCell. So i found some code: - (void)fireTimer { NSMutableString *mutableText = [NSMutableString stringWithString: textLabel.text]; //Takes the first character and saves it into a string NSString…
Genevios
  • 1,115
  • 1
  • 16
  • 29
0
votes
4 answers

Assigning command line arguments to functions

Lets say I wanted to open a function (it opens a file, does something with it, then spits out the results to a different file). Using argv and argc, and from going through all the tutorials online, I'm assuming that if i print argv[0] i get the file…
0
votes
4 answers

Java - how to load method inside class it is defined?

For example I have this code: public class A { private void my_method(){ //do something } } So how can I call that method for code below to use it? I saw in one example it was done like this: public class A { public A { …
Andrius
  • 19,658
  • 37
  • 143
  • 243
0
votes
1 answer

Console to jTextArea1 issue. (voids!?)

class TreeTraversal { public void main(String[] args) throws IOException { System.out.println("Displaying the tree"); theTree.displayTree(); /** how to you print these kind of things? e.g theTree.preOrder(theTree.returnRoot()); in to…
0
votes
2 answers

Error: unknown type name 'record'

This is my code in codeblocks C language sorry i'm new in here #include #include #include struct record { char name[50]; char id[30]; char course[7]; char project[100]; char field[3]; char supervisor[30]; }; struct…
Cheryl Perry
  • 119
  • 1
  • 3
  • 9
0
votes
3 answers

void type variables in c storage

What are void type variable in C? I have rough idea but not sure how i can use them for below scenario. server/ client program I have a struct array which contains hostname, address in server. I want to send it to the client over the socket. How i…
sean
  • 146
  • 2
  • 9
0
votes
1 answer

C++: Class Issues

I'm attempting to make my class do the following... EmployeeHandler: Initializes m_employeeCount to zero. AddEmployee: Invoked by menu option 1. Displays "NEW EMPLOYEE". Prompts the user for the employee’s first name, last name, and pay rate, one…
Bob
  • 1,344
  • 3
  • 29
  • 63
0
votes
1 answer

pchart displays VOID instead of not drawing the line

So I have this code : if($farateze_dec == 0 or $farateze_dec == NULL) { $mediageneraladecembrie = VOID; } elseif($cuteze_dec == 9 or $cuteze_dec == NULL) { $mediageneraladecembrie = VOID; …
Acelasi Eu
  • 914
  • 2
  • 9
  • 30
0
votes
1 answer

Class Errors with Pointers

I'm currently writing a class for a program and this is what I'm attempting to accomplish... Setup: Sets m_ptrEmployee to NULL and m_beginHour to hour. AssignEmployee: Sets m_ptrEmployee to employee. GetEmployeeName: Uses m_ptrEmployee and…
Bob
  • 1,344
  • 3
  • 29
  • 63
0
votes
6 answers

Correct way to get a value?

As part of my AP curriculum I am learning java and while working on a project I wondered which of the following is best way to return a value? public double getQuarters(){ return quarters; } or public void getQuarters(){ …
user2708074
0
votes
1 answer

How to make Pixel variables random?

so Here's a piece of void draw code that I can't figure out. Please explain to me what I'm doing wrong. void draw() { loadPixels(); int x,y,offs,u,v; offs=0; for (y=0;y<988;y++) { for (x=0;x<554;x++)…
0
votes
1 answer

How can I run method from MainActivity to my value class?

I have 2 classes. I want to do that I can call method from value to MainActivity , I don't know if I need to use interface (I don't know how to use interface) MainActivity class: public class MainActivity extends Activity { public void name() {…
user2747616
0
votes
4 answers

Generic copy using void pointer

I implemented a generic quick sort and now I want to accept the array from command line. Following is a function that is supposed to copy character pointers from array argv to base. I am getting segmentation fault. The copy is working fine when I…
Ajinkya
  • 826
  • 1
  • 10
  • 15
0
votes
5 answers

C - How can I sort and print an array in a method but have the prior unsorted array not be affected

This is for a Deal or No Deal game. So in my main function I'm calling my casesort method as such: casesort(cases); My method looks like this, I already realize it's not the most efficient sort but I'm going with what I know: void casesort(float…