static-method

can jax-ws web methods return objects that have static methods?

public class Pojo { private String value; public static void printValue() { System.out.println("value=" + value); } } I would want to return this from a web service as follows: @WebService public class MyService { @WebMethod public Pojo getPojo() { return new Pojo(); } } Can't seem to find the definiti...

Static methods in C#?

What is the performance concern with static method over non-static methods? I have read that Static methods are better in terms of performance but i want to know, how they are faster? If a method is not using any instance member then our compiler should take care of it and treat it as static method. ...

Why is call to static method in Java not being made?

I have a fairly standard creational pattern whereby a class exposes a static method for returning instances of itself, like so: public class MyClass { private MyClass(/*parameter list*/) { // internal construction } public static MyClass GetMyClass(/*parameter list*/) { return new MyClass(/*parameter li...

.NET: Determine the type of “this” class in its static method

Well, in a non-static method I could use this.GetType() and it would return the Type. How can I get the same Type in a static method? Of course, I can't just write typeof(ThisTypeName) because ThisTypeName is known only in the runtime. Thanks! ...

Spaceship objects

I'm trying to make a program which creates a spaceship and I'm using the status() method to display the ship's name and fuel values. However, it doesn't seem to be working. I think I may have messed something up with the status() method. I'm also trying to make it so that I can change the fuel values, but I don't want to create a new met...

Advantage of using a static member function instead of an equivalent non-static member function?

I was wondering whether there's any advantages to using a static member function when there is a non-static equivalent. Will it result in faster execution (because of not having to care about all of the member variables), or maybe less use of memory (because of not being included in all instances)? Basically, the function I'm looking a...

Having a little trouble with this Java code. Beginner probably mixing some things with C#.

package practico1; /** * Programador: Sergio Tapia Gutierrez * Fecha: Lunes 10, Mayo - 2010 * Practico: 1 */ public class Main { public static void main(String[] args) { System.out.println("Esta es una pequena aplicacion para mostrar los"); System.out.println("distintos tipos de datos que existen en J...

Using class/static methods as default parameter values within methods of the same class

I'd like to do something like this: class SillyWalk(object): @staticmethod def is_silly_enough(walk): return (False, "It's never silly enough") def walk(self, appraisal_method=is_silly_enough): self.do_stuff() (was_good_enough, reason) = appraisal_method(self) if not was_good_enough: ...

Trying to use static methods/members, need some help

Hello, I've been spoilt with c# coding the last few years and now I'm back onto c++ and finding that I'm having trouble with stuff that is supposed to be simple. I'm using a third party library for gamedev called DarkGDK (any commands which are prefixed with db), however DGDK isn't the problem. Heres my code: System.h #pragma once #...

Static method vs module function in python

So I have a class in a module that has some static methods. A couple of these static methods just do crc checks and stuff, and they're not really useful outside of the class (I would just make them private static methods in java or C++). I'm wondering if I should instead make them global class functions (outside of the class). Is there...

How to get (sub)class name from a static method in Python?

If I define: class Bar(object): @staticmethod def bar(): # code pass class Foo(Bar): # code pass Is it possible for a function call Foo.bar() to determine the class name Foo? ...

Calling staticmethod inside class level containers intialization

Given the following example class: class Foo: def aStaticMethod(): return "aStaticMethod" aVariable = staticmethod(aStaticMethod) aTuple = (staticmethod(aStaticMethod),) aList = [staticmethod(aStaticMethod)] print Foo.aVariable() print Foo.aTuple[0]() print Foo.aList[0]() Why would the call to aVariable work...