Search Results

Search found 59353 results on 2375 pages for 'class instance variables'.

Page 8/2375 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • When do instance variables get initialized and values assigned?

    - by AKh
    When doees the instance variable get initialized? Is it after the constructor block is done or before it? Consider this example: public abstract class Parent { public Parent(){ System.out.println("Parent Constructor"); init(); } public void init(){ System.out.println("parent Init()"); } } public class Child extends Parent { private Integer attribute1; private Integer attribute2 = null; public Child(){ super(); System.out.println("Child Constructor"); } public void init(){ System.out.println("Child init()"); super.init(); attribute1 = new Integer(100); attribute2 = new Integer(200); } public void print(){ System.out.println("attribute 1 : " +attribute1); System.out.println("attribute 2 : " +attribute2); } } public class Tester { public static void main(String[] args) { Parent c = new Child(); ((Child)c).print(); } } OUTPUT: Parent Constructor Child init() parent Init() Child Constructor attribute 1 : 100 attribute 2 : null When the memory for the atribute 1 & 2 are allocated in the heap ? Curious to know why is attribute 2 is NULL ? Are there any design flaws?

    Read the article

  • Is it appropriate for a class to only be a collection of information with no logic?

    - by qegal
    Say I have a class Person that has instance variables age, weight, and height, and another class Fruit that has instance variables sugarContent and texture. The Person class has no methods save setters and getters, while the Fruit class has both setters and getters and logic methods like calculateSweetness. Is the Fruit class the type of class that is better practice than the Person class. What I mean by this is that the Person class seems like it doesn't have much purpose; it exists solely to organize data, while the Fruit class organizes data and actually contains methods for logic.

    Read the article

  • Verification of UML Class Diagram

    - by Jean Carlos Suárez Marranzini
    This is my UML Class Diagram made in Astah Community, for a tennis scoreboard game. Here's a link to the image (I don't have enough rep to post images): http://i47.tinypic.com/2lsxx90.png Points are calculated based on moves. Moves can be either points (for the player's advantage) or errors (for the opponent's advantage). The Time Machine allows you to travel to previous game states (expressed as scoreboards). The storage component should be able to store matches independently of the serialization format. The serializers and deserializers should be able to do their job regardless of where the storage lies. The GameEngine should be able to apply the rules of the game regardless of the particularities of the game (hence, dependency injection through the Settings class). The outcomes of games, sets and matches should be deducible based on the points and the rules to apply (the logic implementations are there to provide the rules). Could you please verify my design and tell me if there's anything wrong with it? Thanks in advance.

    Read the article

  • Class as first-class object

    - by mrpyo
    Could a class be a first-class object? If yes, how would the implementation look? I mean, how could syntax for dynamically creating new classes look like? EDIT: I mean what example syntax could look like (I'm sorry, English is not my native language), but still I believe this question makes sense - how you give this functionality while keeping language consistent. For example how you create reference for new type. Do you make reference first-class object too and then use something like this: Reference<newType> r = new Reference<newType>(); r.set(value); Well this could get messy so you may just force user to use Object type references for dynamically created classes, but then you loose type-checking. I think creating concise syntax for this is interesting problem which solving could lead to better language design, maybe language which is metalanguage for itself (I wonder if this is possible).

    Read the article

  • Amazon EC2- micro-instance vs single small/medium instance

    - by shashankaholic
    I have a chat application using stack of Openfire, Tomcat6 and MySQL. Currently, i have installed all these servers on single Linux micro-instance(613 MB memory). Even in low user base 10-20 i am encountering CPU overload which is quite obvious here. As, i am new to Amazon EC2 can somebody suggest me how to scale up my architecture according to traffic use? should i use separate micro instances for every app server(openfire,mysql,tomcat6) should i use single small or medium instance for whole server stack. Some factors in context: high reliance on MYSQL high memory usage due to file transfer web-application interacting with other Amazon service like S3,SES

    Read the article

  • Check if a class is subclass of another class in Java

    - by craesh
    Hi! I'm playing around with Java's reflection API and trying to handle some fields. Now I'm stuck with identifying the type of my fields. Strings are easy, just do myField.getType().equals(String.class). The same applies for other non-derived classes. But how do I check derived classes? E.g. LinkedList as subclass of List. I can't find any isSubclassOf(...) or extends(...) method. Do I need to walk through all getSuperClass() and find my supeclass by my own? Thanks! craesh

    Read the article

  • Static member class - declare class private and class member package-private?

    - by Helper Method
    Consider you have the following class public class OuterClass { ... private static class InnerClass { int foo; int bar; } } I think I've read somewhere (but not the official Java Tutorial) that if I would declare the static member classes attributes private, the compiler had to generate some sort of accessor methods so that the outer class can actually access the static member class's (which is effectively a package-private top level class) attributes. Any ideas on that?

    Read the article

  • Saving Variables In An ASP Page

    - by Or Betzalel
    I'm trying to convert a game I made (WindowsFormApplication) to an ASP Page. My Problem is that I have a lot "private" variables in my WindowFormApplication and those variables are important for the game. But when after I Declare all my variables (in my Page_Load), they turn null no matter what I do(click a button, refresh the page). Is there anyway to save my variables between buttons (other than Session, because I'd have to create like 6 more sessions)

    Read the article

  • Routing Apache TracEnv

    - by fampinheiro
    Hello, i have a situation with many trac instances. They all have the same structure in the filesystem. PATH/trac1 PATH/trac2 PATH/trac3 i have this configuration <Location /trac/trac1> SetHandler mod_python PythonInterpreter main_interpreter PythonHandler trac.web.modpython_frontend PythonOption TracEnv PATH/trac1 PythonOption TracUriRoot /trac/trac1 PythonOption PYTHON_EGG_CACHE PATH/eggs/ </Location> <Location /trac/trac2> SetHandler mod_python PythonInterpreter main_interpreter PythonHandler trac.web.modpython_frontend PythonOption TracEnv PATH/trac2 PythonOption TracUriRoot /trac/trac2 PythonOption PYTHON_EGG_CACHE PATH/eggs/ </Location> <Location /trac/trac3> SetHandler mod_python PythonInterpreter main_interpreter PythonHandler trac.web.modpython_frontend PythonOption TracEnv PATH/trac3 PythonOption TracUriRoot /trac/trac3 PythonOption PYTHON_EGG_CACHE PATH/eggs/ </Location> i wonder if it's possible to do something like (TracEnvParentDir is not an option) <Location /trac/{ENV}> SetHandler mod_python PythonInterpreter main_interpreter PythonHandler trac.web.modpython_frontend PythonOption TracEnv PATH/{ENV} PythonOption TracUriRoot /trac/{ENV} PythonOption PYTHON_EGG_CACHE PATH/eggs/ </Location> Thank you for your time. EDIT: TracEnvParentDir is not an option because my structure is the following +---projs +---trac1 ¦ +---public [instance] ¦ +---t1 ¦ ¦ +---common [instance] ¦ ¦ +---g1 [instance] ¦ ¦ +---g2 [instance] ¦ ¦ +---g3 [instance] ¦ ¦ +---g4 [instance] ¦ ¦ +---g5 [instance] ¦ +---t2 ¦ ¦ +---common [instance] ¦ ¦ +---g1 [instance] ¦ ¦ +---g2 [instance] ¦ ¦ +---g3 [instance] ¦ ¦ +---g4 [instance] ¦ ¦ +---g5 [instance] ¦ +---t3 ¦ +---common [instance] ¦ +---g1 [instance] ¦ +---g2 [instance] ¦ +---g3 [instance] ¦ +---g4 [instance] ¦ +---g5 [instance] ¦ +---trac2 +---public [instance] +---t1 ¦ +---common [instance] ¦ +---g1 [instance] ¦ +---g2 [instance] ¦ +---g3 [instance] ¦ +---g4 [instance] ¦ +---g5 [instance] +---t2 ¦ +---common [instance] ¦ +---g1 [instance] ¦ +---g2 [instance] ¦ +---g3 [instance] ¦ +---g4 [instance] ¦ +---g5 [instance] +---t3 +---common [instance] +---g1 [instance] +---g2 [instance] +---g3 [instance] +---g4 [instance] +---g5 [instance] I use the TracEnvParentDir on t1, t2 and t3 and TracEnv on trac1/public and trac2/public I wonder if it's possible to define a part of the url variable.

    Read the article

  • VS2012 - How to manually convert .NET Class Library to a Portable Class Library

    - by Igor Milovanovic
    The portable libraries are the  response to the growing profile fragmentation in .NET frameworks. With help of portable libraries you can share code between different runtimes without dreadful #ifdef PLATFORM statements or even worse “Add as Link” source file sharing practices. If you have an existing .net class library which you would like to reference from a different runtime (e.g. you have a .NET Framework 4.5 library which you would like to reference from a Windows Store project), you can either create a new portable class library and move the classes there or edit the existing .csproj file and change the XML directly. The following example shows how to convert a .NET Framework 4.5 library to a Portable Class Library. First Unload the Project and change the following settings in the .csproj file: <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> to: <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable \$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" /> and add the following keys to the first property group in order to get visual studio to show the framework picker dialog: <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB}; {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>   After that you can select the frameworks in the Library Tab of the Portable Library:   As last step, delete any framework references from the library as you have them already referenced via the .NET Portable Subset.     [1] Cross-Platform Development with the .NET Framework - http://msdn.microsoft.com/en-us/library/gg597391.aspx [2] Framework Profiles in .NET: http://nitoprograms.blogspot.de/2012/05/framework-profiles-in-net.html

    Read the article

  • MATLAB: Automatic detection of relations between workspace variables through functions

    - by Peterstone
    Hi all, I´m trying to write a function what detect this relation between the variables I have got in the workspace: v1 - fft(v2) = 0 Where v1, v2 are variables of my workspace. Sometimes I need to know which variables have a certain numerical relation. If I have thirty, I don´t want to be looking for this relation in "manual way", just itroducing a sentence for each pair of different variables. I would like a function in which I introuce (or I modify this function every time I need it) the sentence (for instance what I wrote before) and the function show me the pair of variables a I am looking for. Does anyone know how to do it? Thank you so much!

    Read the article

  • jQuery how to add class to a parent div which has a 3rd level child div with a specific class name.

    - by Vikram
    Hello friends I have an issue adding a special class to a couple of my divs. My layout is like this. <div class="container"> <div class="grid-6 push-3 equal" style="height: 999px;"> <div class="block"> <div id="mainbody"> <!-- Body content here --> </div> </div> </div> <div class="grid-2 equal" style="height: 999px;"> <div class="block"> <div id="sidebar-a"> <!-- Sidebar-a content here --> </div> </div> </div> <div class="grid-2 equal" style="height: 999px;"> <div class="block"> <div id="sidebar-b"> <!-- Sidebar-b content here --> </div> </div> </div> <div class="grid-2 equal" style="height: 999px;"> <div class="block"> <div id="sidebar-b"> <!-- Sidebar-c content here --> </div> </div> </div> </div> I want to add a different background color to each of my sidebars via CSS and when I code like: #mainbody { background : #fff; } #sidebar-a { background : #eee; } #sidebar-b { background : #ddd; } #sidebar-c { background : #ccc; } It is applying the background only to that specific class but that specific class is not of equal height. I actually need to apply to this <div class="grid-2 equal" style="height: 999px;"> div. Now the issue is that in this <div class="grid-6 push-3 equal" style="height: 999px;"> and class="grid-2 equal" style="height: 999px;"> the class names grid-6 and grid-2 are generated dynamically by my PHP of 960 Grid System and also the style="height: 999px; is generated by a jQuery script for Equal-Columns. What I want is to add a unique class name like this...... Look for a div with a class of .equal which has a child div with a class of .block and which further has a child div with an ID of sidebar-a. IF TRUE then add a class of .sidebar-a to the maindiv which has a class of .equal So that the result looks like this: <div class="grid-6 equal push-3 mainbody" style="height: 999px;"> <div class="grid-2 equal sidebar-a" style="height: 999px;"> <div class="grid-2 equal sidebar-b" style="height: 999px;"> <div class="grid-2 equal sidebar-c" style="height: 999px;"> Then I'll be able to style it like this: .mainbody { background : #fff; } .sidebar-a { background : #eee; } .sidebar-b { background : #ddd; } .sidebar-c { background : #ccc; } Hence I thought since I am anyway using jQuery in my Template, why not use it to deal with this issue. Please feel free to suggest a better way if you have something else in mind.

    Read the article

  • How do I access abstract private data from derived class without friend or 'getter' functions in C++?

    - by John
    So, I am caught up in a dilemma right now. How am I suppose to access a pure abstract base class private member variable from a derived class? I have heard from a friend that it is possible to access it through the base constructor, but he didn't explain. How is it possible? There are some inherited classes from base class. Is there any way to gain access to the private variables ? class Base_button { private: bool is_vis; Rect rButton; public: // Constructors Base_button(); Base_button( const Point &corner, double height, double width ); // Destructor virtual ~ Base_button(); // Accessors virtual void draw() const = 0; bool clicked( const Point &click ) const; bool is_visible() const; // Mutators virtual void show(); virtual void hide(); void move( const Point &loc ); }; class Button : public Base_button { private: Message mButton; public: // Constructors Button(); Button( const Point &corner, const string &label ); // Acessors virtual void draw() const; // Mutators virtual void show(); virtual void hide(); }; I want to be able access Rect and bool in the base class from the subclass

    Read the article

  • What class structure allows for a base class and mix/match of subclasses? (Similar to Users w/ roles)

    - by cdeszaq
    I have a set of base characteristics, and then a number of sub-types. Each instance must be one of the sub-types, but can be multiple sub-types at once. The sub-types of each thing can change. In general, I don't care what subtype I have, but sometimes I do care. This is much like a Users-Roles sort of relationship where a User having a particular Role gives the user additional characteristics. Sort of like duck-typing (ie. If my Foo has a Bar, I can treat it like a ThingWithABar.) Straight inheritance doesn't work, since that doesn't allow mix/match of sub-types. (ie. no multi-inheritance). Straight composition doesn't work because I can't switch that up at runtime. How can I model this?

    Read the article

  • MEF instance management

    - by Lawrence A. Contreras
    I am working on application that has multiple modules and sub modules. Here's what I need to do: ModuleA has a sub module SubModuleA, SubModuleB, SubModuleC. I want to export ModuleA, SubModuleA, SubModuleB, SubModuleC. ModuleA can have multiple instances. Whenever I import ModuleA inside the sub modules, I want to get the correct instance and also when I import SubModuleA,SubModuleB and SubModuleC inside other classes. How can I manage that scenario using MEF? Do I really need to use MEF. Updated: Here's a quick example: public class School { List<Classroom> classRooms { get; set; } } [Export] public class Classroom { List<Teacher> teachers { get; set; } } public class Teacher { List<Student> students { get; set; } } public class Student { [Import] Classroom classroom { get; set; } } As you can see, I want to export the classroom class because I need to import it in the Student class, let's just say that I really need the classroom class inside the student class. I want to skip the part where we pass the classroom to the teacher and from the teacher we'll pass it to the student. But when I import classroom, I want to have the correct instance where that class room contains the teacher of the student.

    Read the article

  • Arguments, local variables, and global variables in Python

    - by prosseek
    In python, there is no way to differentiate between arguments, local variables, and global variables. The easy way to do so might be have some coding convention such as Global variables start with _ and capital letter arguments end with with _ _Global variable = 10 def hello(x_, y_): z = x_ + y_ Is this a Pythonian way to go? I mean, is there well established/agreed coding-standards to differentiate them in python?

    Read the article

  • Arguments, local variables, and global variables coding convention in Python

    - by prosseek
    In python, there is no way to differentiate between arguments, local variables, and global variables. The easy way to do so might be have some coding convention such as Global variables start with _ and capital letter arguments end with with _ _Gvariable = 10 def hello(x_, y_): z = x_ + y_ Is this a Pythonian way to go? I mean, is there well established/agreed coding-standards to differentiate them in python?

    Read the article

  • Return the name of the class instance with the highest 'someValue' instance variable

    - by Timbo
    I have a brand new Objective-C class called test. The test class has an instance variable called someValue, which contains an integer. I create 5 instances of the test class called aTest, bTest, cTest, dTest and eTest. The appropriate synthesize and property declarations for someValue are in place. Is there a clean way of returning the name of the class instance with the highest someValue value out of all the existing test class instances? The number of class instances may vary from the 5 in my example. Note I don't care what the value is, I just want to return the name of the class instance with the highest 'someValue' instance variable. I've tried a few NSMutable arrays however can only get the value not the name of the variable that contains it. Thanks in advance

    Read the article

  • Why is an anonymous inner class containing nothing generated from this code?

    - by Andrew Westberg
    When run through javac on the cmd line Sun JVM 1.6.0_20, this code produces 6 .class files OuterClass.class OuterClass$1.class OuterClass$InnerClass.class OuterClass$InnerClass2.class OuterClass$InnerClass$InnerInnerClass.class OuterClass$PrivateInnerClass.class When run through JDT in eclipse, it produces only 5 classes. OuterClass.class OuterClass$1.class OuterClass$InnerClass.class OuterClass$InnerClass2.class OuterClass$InnerClass$InnerInnerClass.class OuterClass$PrivateInnerClass.class When decompiled, OuterClass$1.class contains nothing. Where is this extra class coming from and why is it created? package com.test; public class OuterClass { public class InnerClass { public class InnerInnerClass { } } public class InnerClass2 { } //this class should not exist in OuterClass after dummifying private class PrivateInnerClass { private String getString() { return "hello PrivateInnerClass"; } } public String getStringFromPrivateInner() { return new PrivateInnerClass().getString(); } }

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >