How do I create a proper Java instance?

I have created a public class helloworld and I am trying to create an object for class Abc. I have used "new" keyword to create an instance for Abc class.But still I am getting an error "non-static variable this cannot be referenced from a static con...
more »

2017-05-22 10:05 (4) Answers

Instantiate New Object

I am new to Java so this is probably a stupid question, but why when I run the following code does name and age not change to "Bob" and 25. I don't get any errors in the system, but it looks like it is not changing them from what they are in the sys...
more »

2017-03-14 20:03 (3) Answers

Generic class with Memory?

This question has been edited from its original version Hi everyone, following your comments, I have modified my original class. The objective of this class is to store two sets of values: The first one is the "applied" one. If the user request th...
more »

2017-03-03 20:03 (0) Answers

Class property array, can't use $this to set value

In the class below, when instantiated, I receive the following error: '$this' (T_VARIABLE) in your code on line 12 'default_timestamp' => $this->_time, I'm confused because when the object is instantiated, I assume $_time is accessible for use, how...
more »

2017-02-26 05:02 (1) Answers

Java Class Instantiation Order

I got this code : public class Sgl { private static Sgl sgl = new Sgl(); private static int count = 0; public static Sgl getSgl() { return sgl; } public static int getCount() { return count; } private Sgl(){System.out.pri...
more »

2017-02-12 20:02 (0) Answers

Ada Generics: Stack vs Heap Clarification

So I have an assignment that says: Please use generic instantiations of packages/classes. Space for each BMR (matrix) must be allocated in the system stack within the generic package/template, probably during generic instantiation! You specificall...
more »

2017-02-05 08:02 (1) Answers

call python3 class with methods

I have a file named: This file contains the following class: Im trying to call my class BrickSetSpider, with its methods, and ultimately return the value of parse_page_urls when running this program like python However, when i ...
more »

2017-01-29 17:01 (2) Answers

PHP how to dynamically instantiate a class

I am new to PHP, and I tried to dynamically instantiate a class like this: $var = new \App\$str; But I keep getting this error: unexpected variable $str after '\', expected: identifier. I know it is possible, but I am just not sure what the ex...
more »

2017-01-24 11:01 (1) Answers

Python class - chaining instance methods

I've started to build my class in this fashion (more like a regular function): ex 1 class Child(Parent): def __init__(self,user): Parent.__init__(self, user) search = filter = api.filter(search) ...
more »

2017-01-03 20:01 (4) Answers

Passing a class and calling a method on it

Consider a class extending Fragment called MyFragmentClass which has newInstance(args) implemented. What I want to do is make a getter for anything extending MyFragmentClass so I can make a new Fragment via newInstance(args). Something like: <T ...
more »

2016-10-30 21:10 (1) Answers

class constructor that calculates input using C#

Hello and thanks for checking my post. New to C# and Oop in general. Learning has been smooth so far but I'm running into issues when I try to create (and call) a constructor that calculates data input by user. If possible: I would like to create 3 ...
more »

2016-10-23 07:10 (4) Answers

MessageShow in another class?

This is my first time trying to implement separate class into form class, rather than just having it all in the form class. How do I go about connecting the two? When the button is clicked, I wanted to be able to have it show the letter grade with Me...
more »

2016-10-18 23:10 (2) Answers

Cannot instantiate class inside itself

I'm writing a blackjack program in Java and I've come across a problem when learning to using inner classes. I'm attempting to instantiate a Blackjack object inside itself to call the inner class Card's methods, but the program cannot find the Blackj...
more »

2016-10-07 09:10 (1) Answers

Instantiate generic type from variable

I would like to instantiate a new object where the type and generic type are defined as variables. The final result could look like the newListOfObjects created manually here: var newListOfObjects = new List<TabViewModel>(); Where TabViewMod...
more »

2016-10-06 09:10 (2) Answers