inner-classes Questions

1

Solved

class A { private: int a; public: class B { public: B(int a) : b(a) {} int b; }; }; int main(void) { return 0; } clang (-Weverything) warns: t.cpp(10,15): warning: constructor parame...
Undersecretary asked 24/7, 2024 at 13:25

3

Solved

What are the differences and the similarities between composition and inner classes? I am trying to learn the principles of Java and try to figure out the whole image. For me is better to make ana...
Hartung asked 1/11, 2016 at 13:21

15

Solved

I'm playing with lambdas in Java 8 and I came across warning local variables referenced from a lambda expression must be final or effectively final. I know that when I use variables inside anonymou...
Nikos asked 5/1, 2014 at 19:30

2

Solved

Working on a real-life project, I've stumbled across the weird behavior of some (versions of some) compilers. Consider the following class declaration(s): struct OptionalsStruct { struct InnerType...
Joycejoycelin asked 22/3, 2023 at 16:38

16

Solved

I have a situation like so... class Outer(object): def some_method(self): # do something class Inner(object): def __init__(self): self.Outer.some_method() # <-- this is the line in quest...
Intransigent asked 7/1, 2010 at 23:49

5

Solved

I have the following piece of code: public class MyClass { class Inner { int s, e, p; } public static void main(String args[]) { Inner in; } } Up to this part the code is fine, but I am ...
Plumley asked 2/10, 2012 at 12:21

3

Solved

I was trying inner classes in Kotlin and came across this error but didn't quite understand it. I tried to look at the documentation here but didn't quite get any direction as to how outer classes ...
Tinkle asked 15/5, 2018 at 17:18

6

Solved

I read about Structuring Unit Tests with having a test class per class and an inner class per method. Figured that seemed like a handy way to organize the tests, so I tried it in our Java project. ...
Skirr asked 6/1, 2012 at 13:9

11

Solved

I have the following code: class Hello { class Thing { public int size; Thing() { size = 0; } } public static void main(String[] args) { Thing thing1 = new Thing(); System.out.println("...
Strontia asked 5/3, 2012 at 1:31

3

Solved

I am trying to reference an inner class from another inner class. I have tried both : class Foo(object): class A(object): pass class B(object): other = A and class Foo(object): class A(...
Studdingsail asked 12/2, 2017 at 8:9

13

I am reviewing the concept of inner classes in java. so far from what I've understood and applied java inner classes has a link or access to the methods and fields of its outer/ enclosing class. M...
Qulllon asked 9/7, 2012 at 15:22

2

Solved

I'm trying to ignore some generated classes, and the classes get ignored fine. But if those classes have inner classes, those classes still get included, despite the parent class being excluded. Th...
Halla asked 22/8, 2017 at 9:56

12

Solved

I'm trying to make a Tetris game and I'm getting the compiler error when I try to create an object Shape is not an enclosing class public class Test { public static void main(String[] args) { S...
Carricarriage asked 27/11, 2013 at 20:44

4

Solved

Consider this code: class Outer { class Inner } In Java it would be possible to create an instance of Inner with: Outer.Inner inner = new Outer().new Inner(); I know I can write this in Scal...
Calculation asked 11/11, 2011 at 11:3

12

Solved

class OuterClass { class InnerClass { static int i = 100; // compile error static void f() { } // compile error } } Although it's not possible to access the static field with OuterClass.Inne...
Subtropics asked 23/12, 2009 at 15:46

1

Solved

First of all, allow me to explain a "behaviour" that I observed, then I will ask in "Example" section. Inner-class-reference behaviour In Java we can have (non-static) inn...
Dig asked 8/5, 2022 at 10:20

11

Solved

I'd like to create a User Class for my new website. However, this time, I was thinking of creating it a little bit differently... Java, C++, and even Ruby (and probably other programming languages)...
Bronwynbronx asked 7/5, 2013 at 16:39

28

Solved

What is the main difference between an inner class and a static nested class in Java? Does design / implementation play a role in choosing one of these?
Intradermal asked 16/9, 2008 at 8:22

4

Solved

Whenever EditText string is changed, onTextChanged is called. Now when I start a new Activity and send data through Bundle, onTextChanged is not called. if( getIntent().getExtras() != null) { B...
Mallee asked 28/8, 2016 at 9:56

6

Solved

The Java Tutorial says that since an inner class is associated with an instance of the enclosing class, it (the inner class) cannot define any static members itself. It's interesting for me why ca...
Sard asked 18/12, 2011 at 21:7

2

Solved

Recently, I ran into a mysterious problem in an android project, which I described here. I somehow solved the problem, but still don't know the exact reason behind it. Let's say I want to call a ...
Vanpelt asked 28/1, 2012 at 5:27

3

Solved

Below is a (slightly) stripped down response I get from a REST API upon successful creation of a new "job code" entry. I need to deserialize the response into some classes, but I'm stumpe...
Sungod asked 31/7, 2014 at 6:38

7

I'm trying to understand scope in nested classes in Python. Here is my example code: class OuterClass: outer_var = 1 class InnerClass: inner_var = outer_var The creation of class does not com...
Sudiesudnor asked 19/11, 2009 at 18:53

2

Solved

We know that a non-static inner class can be accessed using the instance of the outer class, so a static method is less meaningful inside a non-static class. But from Java 16 static methods are all...
Ellswerth asked 25/7, 2021 at 18:2

6

Solved

Can someone please point me towards some nice resources for understanding and using nested classes? I have some material like Programming Principles and things like this IBM Knowledge Center - Nest...
Marylyn asked 31/12, 2010 at 17:14

© 2022 - 2025 — McMap. All rights reserved.