38 Solved Topics

Remove Filter
Member Avatar for
Member Avatar for theashman88

I know this has been asked before, but I can't find any simple answers for a noob like me in C#. What exactly is a static method. I mean what does it mean to be static vs. nonstatic. I know in the code with the main method we use `public …

Member Avatar for RichardGalaviz
1
305
Member Avatar for Adami

Hi guys, I wrote the following code: public static boolean match(int[] a , int[] pattern) { //need to use the overloaded method, in order to work with the static method. return match(a,pattern,0,0); } /** This is an overloaded method that match between a pattern to a given string (as an …

Member Avatar for Adami
0
3K
Member Avatar for moaz.amin.37

hi i can't undestanding this why the main function in java is static and static function can call using class name. And why we declare main function as public. i can not understanding this procedure of main function in java. plz help me.

Member Avatar for stultuske
0
309
Member Avatar for moaz.amin.37

my question is that when we use static data member and ststic function and nobody can not satisfy me about this question i need actual reason of using the static data member and ststic member function

Member Avatar for deceptikon
0
843
Member Avatar for Labdabeta

Hello, I noticed that in c++ everything that can be done using a static function in a class could be done by using a public function in the same namespace. Assuming that you bind your classes in a namespace these functions do not take up names in the global namespace. …

Member Avatar for mike_2000_17
0
199
Member Avatar for CPT

currently I have a class function: class MyClass{ static int E(int A,int B, int C){ //function code } }; //and I call it like this : MyClass::E(1,2,3); //what I would like to do is call it in this way: E(1,2,3); //my current macro definition is this #define E(a,b,c) Myclass::E((a),(b),(c)) how …

Member Avatar for JasonHippy
0
306
Member Avatar for sliobra

I was doing my assignment till I reached this point. Add a static Date toDate(String str) method to the DateTest class. If the method is called with a string like “23/5/2013”, it will create and return the corresponding date object. If the input string is not valid date, the method …

Member Avatar for JamesCherrill
0
192
Member Avatar for nickerst

So I have been working on this project for quite some time and I can't figure out why I keep getting an "Illegal Start of Expression" error. I tried moving the variables above the main method and that only returned the same error but instead of the error occuring at …

Member Avatar for nickerst
0
318
Member Avatar for Eyeteeorg

I'm just learning html but already have a domain, so I did a quick and dirty under construction page to replace the advertising-littered default page that the webhost was using. It's dirt-simple and not very good, but I'll make it better as time goes on. Is there any rule I'm …

Member Avatar for margaret224
0
209
Member Avatar for marnun

Here is the exercise: > fileWord > Write the definition of a function named fileWord that receives a string argument that is the name of a file containing words. > > The first time the function is called, it returns the first word of the file whose name it was …

Member Avatar for marnun
0
259
Member Avatar for James19142

I need a way to do a cast without being returned a pointer to a new address but, the same address as the original. Something like this: derivedClass something_derived; baseClass* basePointer = &something_dervived; derivedClass* derivedPointer = static_cast <derivedClass*> (basePointer); /* my problem is "derivedPointer" isnt assigned the same address as …

Member Avatar for James19142
0
185
Member Avatar for tabj

I need a help? I m designing a webpage. I have used <**div**>s everywhere, from header to footer, moreover I have used **relative** **positioning** with **top** and **right** tag. Somewhere top value has gone -1200 and so. At last I m left with about 800px of useless area below the …

Member Avatar for lps
0
852
Member Avatar for Pyler

I use dr java for linux to run my code. I've been running into a bunch of errors recently while running this simple program. The code compiles fine but whenever I run the java file, I get the error; Static Error: Undefined name here's my code; (I've got two files, …

Member Avatar for TrustyTony
0
2K
Member Avatar for deshazer.jad

My goal is to create a clone of minesweeper. I've created a custon component that extends the JButton class, for each of the minesweeper buttons. I've called this new class SweeperButton. the game board is going to be made in another class by creating a two deminsional array of SweeperButtons, …

0
170
Member Avatar for Viped

Hi, I am trying to make simple gui which switches jpanel inside jframe but my IDE says "Cannot make static reference to non static method setPage(int) from the type Main". Why is that? There is no static modifier on actionPerformed or at setPage or actually anywhere else than public static …

Member Avatar for JamesCherrill
0
164
Member Avatar for rahul.ch

Hey guys, I'm a starter so I had a doubt related to placement of a static variable. On line 5, for "static int d=5" compiler issues "illegal start of expression". But when I place it outside main() as Instance variable it works and prints "Hello 5". Why this thing? public …

Member Avatar for rahul.ch
0
199
Member Avatar for magg93

I'm really confused with this! I have 2 classes, Club and Membership. In Membership I have the method, getMonth(), and in Club I have joinedMonth() which takes the parameter, 'month' - so a user enters a month and then I want it to return the Membership's which joined in that …

Member Avatar for magg93
0
535
Member Avatar for sciwizeh

Hello all, been a while since I've asked a question. I'm working on a project just to practice and for fun and I've run into a snag. I'm working on a painting type program and I'm trying to get a generic Buffer class for the images so I can use …

Member Avatar for sciwizeh
0
2K
Member Avatar for jt_4285

i am newbie to java.i am trying to run a program to show "static method" and "static variable ".my code is below.i am compling it on netbeans 7.01 and everytime i am getting the error.: "main method not found in class static_demo.Static_demo, please define the main method as: public static …

Member Avatar for stultuske
0
229
Member Avatar for warlord902

I have a static class, with all methods and fields static. My methods in that class are going to use a static field declared in that class. I want that static variable(which can not be made final) to be initialized with a value taken from a database when that static …

Member Avatar for warlord902
0
208
Member Avatar for warlord902

I have a kind of doubt, suppose I have a class like this: [CODE] public class AA{ public static createUser(String a, int b){ User usr=new User(a,b); BB.storeUser(usr); } } [/CODE] Now, if multiple threads call this createUser() method of this class at the same time, will it cause any kind …

Member Avatar for warlord902
0
188
Member Avatar for Staric

What I have is a linksys wrt54gs(dd-wrt) router assigning private ip's to my workstations. I also have a Windows Server which i need accessible for Windows Remote Desktop Connection to my remote office in Costa Rica. I'd like to have the server have one of my 5 static public ip's(so …

0
176
Member Avatar for arjunpk

Hi, I have a program which has to do a lot of lookup. there are multiple threads running in parallel and all of these threads have to do a lookup on the same list of words. Currently i'm storing the list of words in a dictionary in each of the …

Member Avatar for Momerath
0
236
Member Avatar for hackit

i want to make a program that contains two main classes and they call each other. [CODE]class Main1 { public static void main(String arg[]) { for(int i=0;i<5;i++) System.out.println(i); Main2 m1=new Main2(); } } class Main2 { public static void main(String arg[]) { static int j=0; for(int i=0;i<5;i++) System.out.println(i); if(j==3) break; …

Member Avatar for hackit
0
178
Member Avatar for Arkrothe

What will happen? Here's a code that i tried, it works but i don't really get what's actually happening or how many instances of the static test t are getting created. [CODE] #include<iostream> using namespace std; class Test { public: static Test t; void hello() { cout<<"this line shall be …

Member Avatar for Arkrothe
0
236
Member Avatar for naffan

Hi all, I've been doing some reading about calling a non static variable or method from a static context, and almost but not quite have my head around what exactly is going on. I've read the text but can't seem to put that into context, so please bare with me. …

Member Avatar for naffan
0
619
Member Avatar for warlord902

I have some doubt regarding how class variable gets initialized, both static and non static. I mean, suppose I have a class like below. [CODE] public class MyClass{ public static HashMap<String,Buddy> buddiesMap= new HashMap<String,Buddy>(); public static ArrayList<String> buddiesList=new ArrayList<String>(); public static HashMap<String,ImageIcon> avatarMap=new HashMap<String, ImageIcon>(); public static ServerConnection con=new ServerConnection(); …

Member Avatar for thekashyap
0
536
Member Avatar for tracydo

Hi, I need help with some small exercises. I'll try my best to provide my code but these are ones that I don't know how. So... maybe you can help me with yours! Thanks 1. Question 1: A program contains the following method definition: [CODE] public static int cube(int num) …

Member Avatar for SMITA6076
0
507
Member Avatar for techie1991

Even after looking at a lot of books, I am not able to understand the problem in the following code: [CODE] //1.c static int y=23; void abc(int a){ printf("%d\n",a); } [/CODE] [CODE] //2.c #include<stdio.h> #include "1.c" int main(){ abc(12); printf("\n"); printf("%d\n",y); return 0; } [/CODE] I can understand that the …

Member Avatar for techie1991
0
233
Member Avatar for SMITA6076

I have two classes. The first class is called [ICODE]EmployeePayRoll.java[/ICODE] (this compiles fine) and the second is called [ICODE]TestEmployeePayRoll.java[/ICODE] (this does not compile). The trouble I'm having is that I'm trying to pass in methods as parameters when I instantiate my objects in the main method of the test class. …

Member Avatar for SMITA6076
0
291

The End.