Questions tagged [initializing]

115 questions
21
votes
3 answers

Java defining or initializing attributes of a class

Is there a difference between defining class attributes and initializing them? Are there cases where you want to do one over the other? Example: The following code snippets should point out the difference that I mean. I'm using a primitive and an…
ChrisMcJava
  • 2,145
  • 5
  • 25
  • 33
19
votes
7 answers

Dynamically allocating and setting to zero an array of floats

How do I automatically set a dynamically allocated array of floats to zero(0.0) during allocation Is this OK float* delay_line = new float[filter_len]; //THIS memset(delay_line, 0.0, filter_len); //can I do this for a float?? //OR THIS for (int i…
miki
16
votes
2 answers

Initializing a pointer in a separate function in C

I need to do a simple thing, which I used to do many times in Java, but I'm stuck in C (pure C, not C++). The situation looks like this: int *a; void initArray( int *arr ) { arr = malloc( sizeof( int ) * SIZE ); } int main() { initArray(…
pechenie
  • 1,908
  • 2
  • 18
  • 17
12
votes
9 answers

C# constructors

Could someone advice me on what approach to take when writing C# constructors? In other languages, like C++, everything is fine - you usually don't make the internal fields visible and provide getters / setters for them. This means, you could…
Yippie-Ki-Yay
  • 22,026
  • 26
  • 90
  • 148
7
votes
1 answer

What is the meaning of the log from tag:"szipinf" and text:"Initializing inflate state" from Logcat

I am a new programmer for Android, so please excuse my knowledge and also my English because it is not my first language. So I am having a log with the tag:"szipinf" and text:"Initializing inflate state" and I don`t know what it means.... I also…
5
votes
5 answers

'Bracket initializing'. (C++)

I'm learning C++ at the moment, C++ Primer plus. But I just felt like checking out the cplusplus website and skip a little forward to file handling. I pretty much know the basics of file handling coming from java, php, visual basic. But I came…
5
votes
5 answers

What gets called when you initialize a class without a constructor?

So when a class has a private constructor you can't initialize it, but when it doesn't have a constructor you can. So what is called when you initialize a class without a constructor? As example, what is called here (new b())?? public class a { …
Tvrd
  • 53
  • 1
  • 6
4
votes
0 answers

JavaFX Error occured during initializing of boot layer (IntelliJ)

i am using javafx for the first time and i get an error when i run a simple program : Error occurred during initialization of boot layer java.lang.module.FindException: Hash of javafx.base…
appleuser
  • 83
  • 8
4
votes
2 answers

can somebody explain how this works?

I have this line of code. class ButtonPanel extends JPanel implements ActionListener { public ButtonPanel() { yellowButton = new JButton("Yellow"); and It works, I thought Java needs to know the type of yellowButton before…
sliucon13
  • 43
  • 2
4
votes
2 answers

initialize char array with quotes and curly braces

I'm little confused. What is the logically difference between these codes? #include using namespace std; int main(){ char a[5]="ABCD"; // this cout << a; return 0; } Second is char a[5]={"ABCD"}; // this Third is char…
Asif Mushtaq
  • 3,658
  • 4
  • 44
  • 80
4
votes
3 answers

NullPointerException when calling a getter

I have already done research on this question, and also tried to figure it out by myself but no luck. So I decided to ask it. Basic info: There are two classes. FBClient, and State. In FBClient, I have a static variable of it's type, fbc, a…
Franko Leon Tokalić
  • 1,457
  • 3
  • 22
  • 28
3
votes
1 answer

Initializing variable in for-loop

I have code like this: TextView wyniszczenie_zakres_bmi = (TextView)t.findViewById(R.id.wyniszczenie_zakres_bmi); TextView wychudzenie_zakres_bmi = (TextView)t.findViewById(R.id.wychudzenie_zakres_bmi); TextView niedowaga_zakres_bmi =…
Marcin Zaremba
  • 253
  • 1
  • 3
  • 11
3
votes
5 answers

Initializing an array of struct in one line? (in C)

I have a 2d array of structs like this, MapStruct myMap[50][50]; So we can initialize like this, myMap[0][0].left = 0; myMap[0][0].up = 1; myMap[0][0].right = 5; I know that I can also use the below example, MapStruct myMap[50][50] = { {0,1,5},…
Bob
  • 31
  • 1
  • 2
3
votes
2 answers

How to initialize multiple variables together?

I need to initialize several variables with the same value in VBScript. The only way I can find is for example x = 5 : y = 5 : z = 5. Is there a way similar to x = y = z = 5?
AhmedWas
  • 1,205
  • 3
  • 23
  • 38
3
votes
1 answer

initializing structs using user-input information

I am trying to make a program that works with poker (texas holdem) starting hands; each hand has a value from 1 to 169, and i want to be able to input each card and whether they are suited or not, and have those values correspond to a series of…
johnny boy
  • 31
  • 2
1
2 3 4 5 6 7 8