Search Results

Search found 3773 results on 151 pages for 'args'.

Page 118/151 | < Previous Page | 114 115 116 117 118 119 120 121 122 123 124 125  | Next Page >

  • vs2002: c# multi threading question..

    - by dotnet-practitioner
    I would like to invoke heavy duty method dowork on a separate thread and kill it if its taking longer than 3 seconds. Is there any problem with the following code? class Class1 { /// <summary> /// The main entry point for the application. /// </summary> /// [STAThread] static void Main(string[] args) { Console.WriteLine("starting new thread"); Thread t = new Thread(new ThreadStart(dowork)); t.Start(); DateTime start = DateTime.Now; TimeSpan span = DateTime.Now.Subtract(start); bool wait = true; while (wait == true) { if (span.Seconds>3) { t.Abort(); wait = false; } span = DateTime.Now.Subtract(start); } Console.WriteLine("ending new thread after seconds = {0}", span.Seconds); Console.WriteLine("all done"); Console.ReadLine(); } static void dowork() { Console.WriteLine("doing heavy work inside hello"); Thread.Sleep(7000); Console.WriteLine("*** finished**** doing heavy work inside hello"); } }

    Read the article

  • What is my error in a map in java?

    - by amveg
    Hello everyone I am trying to solve this problem: http://www.cstutoringcenter.com/problems/problems.php?id=4, but I cant figure out why my code doesnt solve this, I mean in the "for" how can I can multiply the letters? what is my error?, It just tell always 7, but I want to multiple all the letters, I hope you can help me enter code here public class ejercicio3 { public static void main(String args[]) { Map<Character, Integer> telefono = new HashMap<Character, Integer>(); telefono.put('A', 2); telefono.put('B', 2); telefono.put('C', 2); telefono.put('D', 3); telefono.put('E', 3); telefono.put('F', 3); telefono.put('G', 4); telefono.put('H', 4); telefono.put('I', 4); telefono.put('J', 5); telefono.put('K', 5); telefono.put('L', 5); telefono.put('M', 6); telefono.put('N', 6); telefono.put('O', 6); telefono.put('P', 7); telefono.put('R', 7); telefono.put('S', 7); telefono.put('T', 8); telefono.put('U', 8); telefono.put('V', 8); telefono.put('W', 9); telefono.put('X', 9); telefono.put('Y', 9); String mensaje = "Practice"; int producto = 1; for (char c : mensaje.toCharArray()) { if (telefono.containsKey(c)) { producto = telefono.get(c) * producto; System.out.println(producto); } } } }

    Read the article

  • (Java) Get value of string loaded into dynamic-type object?

    - by Michael
    I'm very new to Java (~10 days), so my code is probably pretty bad, but here's what I've got: ArgsDataHolder argsData = new ArgsDataHolder(); // a class that holds two // ArrayList's where each element // representing key/value args Class thisArgClass; String thisArgString; Object thisArg; for(int i=2; i< argsString.length; i++) { thisToken = argsString[i]; thisArgClassString = getClassStringFromToken(thisToken).toLowerCase(); System.out.println("thisArgClassString: " + thisArgClassString); thisArgClass = getClassFromClassString(thisArgClassString); // find closing tag; concatenate middle Integer j = new Integer(i+1); thisArgString = getArgValue(argsString, j, "</" + thisArgClassString + ">"); thisArg = thisArgClass.newInstance(); thisArg = thisArgClass.valueOf(thisArgString); argsData.append(thisArg, thisArgClass); } The user basically has to input a set of key/value arguments into the command prompt in this format: <class>value</class>, e.g. <int>62</int>. Using this example, thisArgClass would be equal to Integer.class, thisArgString would be a string that read "62", and thisArg would be an instance of Integer that is equal to 62. I tried thisArg.valueOf(thisArgString), but I guess valueOf(<String>) is only a method of certain subclasses of Object. For whatever reason, I can't seem to be able to cast thisArg to thisArgClass (like so: thisArg = (thisArgClass)thisArgClass.newInstance();, at which point valueOf(<String>) should become accessible. There's got to be a nice, clean way of doing this, but it is beyond my abilities at this point. How can I get the value of the string loaded into a dynamically-typed object (Integer, Long, Float, Double, String, Character, Boolean, etc.)? Or am I just overthinking this, and Java will do the conversion for me? :confused:

    Read the article

  • need help with some basic java.

    - by Racket
    Hi, I'm doing the first chapter exercises on my Java book and I have been stuck for a problem for a while now. I'll print the question, prompt/read a double value representing a monetary amount. Then determine the fewest number of each bill and coin needed to represent that amount, starting with the highest (assume that a ten dollar bill is the maximum size needed). For example, if the value entered is 47,63 (forty-seven dollars and sixty-three cents), and the program should print the equivalent amount as: 4 ten dollar bills 1 five dollar bills 2 one dollar bills 2 quarters 1 dimes 0 nickels 3 pennies" etc. I'm doing an example exactly as they said in order to get an idea, as you will see in the code. Nevertheless, I managed to print 4 dollars, and I can't figure out how to get "1 five dollar", only 7 dollars (see code). Please, don't do the whole code for me. I just need some advice in regards to what I said. Thank you. import java.util.Scanner; public class PP29 { public static void main (String[] args) { Scanner sc = new Scanner (System.in); int amount; double value; double test1; double quarter; System.out.println("Enter \"double\" value: "); value = sc.nextDouble(); amount = (int) value / 10; // 47,63 / 10 = 4. int amount2 = (int) value % 10; // 47 - 40 = 7 quarter = value * 100; // 47,63 * 100 = 4736 int sum = (int) quarter % 100; // 4763 / 100 => 4763-4700 = 63. System.out.println(amount); System.out.println(amount2); } }

    Read the article

  • list all files from directories and subdirectories in Java

    - by Adnan
    What would be the fastest way to list the names of files from 1000+ directories and sub-directories? EDIT; The current code I use is: import java.io.File; public class DirectoryReader { static int spc_count=-1; static void Process(File aFile) { spc_count++; String spcs = ""; for (int i = 0; i < spc_count; i++) spcs += " "; if(aFile.isFile()) System.out.println(spcs + "[FILE] " + aFile.getName()); else if (aFile.isDirectory()) { System.out.println(spcs + "[DIR] " + aFile.getName()); File[] listOfFiles = aFile.listFiles(); if(listOfFiles!=null) { for (int i = 0; i < listOfFiles.length; i++) Process(listOfFiles[i]); } else { System.out.println(spcs + " [ACCESS DENIED]"); } } spc_count--; } public static void main(String[] args) { String nam = "D:/"; File aFile = new File(nam); Process(aFile); } }

    Read the article

  • Deprecated functions not spotted if using "System::Threading::ThreadState" (and others!) C++ VS2005/

    - by Fishboy
    Hi, I'm facing an issue with c++ on vs2005 and also vs2008... here's how you can reproduce the issue.... create a new (c++) project called 'test' (file|new|project) select "Windows Forms Application" and add the 'stdio.h' include and the code fragment below into the test.cpp source file..... -------------------start of snippet-------------------- #include <stdio.h> ... int main(array<System::String ^> ^args) { int i; System::Threading::ThreadState state; char str[20]; sprintf (str, "%s", "test string"); ... -------------------end of snippet-------------------- If you compile the code as above (you'll have to 'buildall' first), you'll get two warnings about 'i' and 'state' being unreferenced (nothing about sprintf being deprecated). If you comment out "System::Threading :Thread state;", you'll get one warning about 'i' being unreferenced and another warning (C4996) for the 'deprecated' sprintf statement.... This issue also occurs for "System::Windows::Forms::MessageBoxIcon", "System::Base64FormattingOptions" (and perhap all 'enum class' types!) Anyone know of the cause and workaround to the issue demonstrated here ( i have other files that demonstate this issue..). (I had started a thread on msdn, but then found this site! see link below) Visual Studio 2005 has stopped warning about deprecated functions

    Read the article

  • C Map String to Function

    - by Scriptonaut
    So, I'm making a Unix minishell, and have come to a roadblock. I need to be able to execute built-in functions, so I made a function: int exec_if_built_in(char **args) It takes an array of strings(the first being the command, and the rest being arguments). For non built-in commands I simply use something like execvp, however I need to find a way to map the first string to a function. I was thinking of making two arrays, one of strings, and another with their corresponding function pointers. However, since many of these functions will be different(return and accept different things), this approach won't work. I also thought of making an array of structs with a name property and a function pointer property, however once again due to the varied nature of the functions I'll be using, this won't work. So, what's the best way to execute a function based on the input of a string? How do I map a string to a certain function? I'm not very familiar with function pointers so I may be missing something. Thank you guys for the help :)

    Read the article

  • Printing distinct integers in an array

    - by ???
    I'm trying to write a small program that prints out distinct numbers in an array. For example if a user enters 1,1,3,5,7,4,3 the program will only print out 1,3,5,7,4. I'm getting an error on the else if line in the function checkDuplicate. Here's my code so far: import javax.swing.JOptionPane; public static void main(String[] args) { int[] array = new int[10]; for (int i=0; i<array.length;i++) { array[i] = Integer.parseInt(JOptionPane.showInputDialog("Please enter" + "an integer:")); } checkDuplicate (array); } public static int checkDuplicate(int array []) { for (int i = 0; i < array.length; i++) { boolean found = false; for (int j = 0; j < i; j++) if (array[i] == array[j]) { found = true; break; } if (!found) System.out.println(array[i]); } return 1; } }

    Read the article

  • multiplying all elements in an array by an outside number?

    - by prodo
    I need to multiple all the values in an array by 3000 which in turn would create a new array that I will use to subtract from another array. I've tried to create a separate method that would do that for me but all I got back in the multiplied array was a bunch of numbers and symbols strangely? here is the code that I wrote public static void main(String[] args) { int numberOfTaxpayers = Integer.parseInt(JOptionPane.showInputDialog("Enter how many users you would like to calculate taxes for: "); int[] usernumChild = new int[numberOfTaxPayers]; for (int i = 0; i < usernumChild.length; i++) { usernumChild[i] = Integer.parseInt(JOptionPane.showInputDialog("Enter number of children for user "+ (i+1) +": ")); }//this for loop finds out the number of children per user so we can later multiply each input by 3000 to create an array that determine dependency exemption for each user int[] depndExemp = multiply(usernumChild, 3000);//this was the calling of the multiply method... somewhere here is the error!! }//end main method public static int[] multiply(int[] children, int number) { int array[] = new int[children.length]; for( int i = 0; i < children.length; i++) { children[i] = children[i] * number; }//end for return array; }//this is the method that I was shown in a previous post on how to create return an array in this the dependency exemption array but when I tested this by printing out the dependency array all I received were a jumble of wrong numbers.

    Read the article

  • What is causing this template-related compile error? (c++)

    - by Setien
    When I try to compile this: #include <map> #include <string> template <class T> class ZUniquePool { typedef std::map< int, T* > ZObjectMap; ZObjectMap m_objects; public: T * Get( int id ) { ZObjectMap::const_iterator it = m_objects.find( id ); if( it == m_objects.end() ) { T * p = new T; m_objects[ id ] = p; return p; } return m_objects[ id ]; } }; int main( int argc, char * args ) { ZUniquePool< std::string > pool; return 0; } I get this: main.cpp: In member function ‘T* ZUniquePool<T>::Get(int)’: main.cpp:12: error: expected `;' before ‘it’ main.cpp:13: error: ‘it’ was not declared in this scope I'm using GCC 4.2.1 on Mac OS X. It works in VS2008. I'm wondering whether it might be a variation of this problem: http://stackoverflow.com/questions/1364837/why-doesnt-this-c-template-code-compile But as my error output is only partially similar, and my code works in VS2008, I am not sure. Can anyone shed some light on what I am doing wrong?

    Read the article

  • How to delete Drawn Line in java?

    - by Jeyjey
    Hello Folks, well this is my code: import javax.swing.; import javax.; import java.awt.; import java.awt.Color; import java.awt.Graphics.; import java.awt.event.*; import javax.swing.UIManager; public class SimpleGUI extends JFrame{ public SimpleGUI(){ this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) ; } public void go(){ Drawpanel = new Mypanel(); JFrame frame = new JFrame("Chasing Line"); frame.getContentPane().add(BorderLayout.CENTER, Drawpanel); frame.setSize(300,300); frame.setVisible(true); Drawpanel.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() { public void mouseMoved(java.awt.event.MouseEvent evt) { DrawpanelMouseMoved(evt); } }); } public void DrawpanelMouseMoved(java.awt.event.MouseEvent evt) { xpos=evt.getX(); ypos=evt.getY(); System.out.println("Coordinates : X :"+ xpos+"Y: "+ypos); Drawpanel.paintImage(xpos,ypos); } class Mypanel extends JPanel{ public void paintImage(int xpost,int ypost){ Graphics d = getGraphics(); d.setColor(Color.black); d.drawLine(xpost, 0, xpost, this.getHeight()); d.setColor(Color.red); d.drawLine(0, ypost, this.getWidth(),ypost); this.validate(); } } // end the inner class public static void main(String[] args){ try { UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch(Exception e) { System.err.println("Look and feel not set"); } SimpleGUI win = new SimpleGUI(); win.go(); } Mypanel Drawpanel; private int xpos=0; private int ypos=0; } // close SimpleGUI class The problem is how can i delete the old lines?, i mea,make only the current x and y lines appear on the screen, make the intersection between both lines "follow" the mouse pointer. thanks for any reply.

    Read the article

  • How do I code a tree of objects in Haskell with pointers to parent and children?

    - by axilmar
    I've got the following problem: I have a tree of objects of different classes where an action in the child class invalidates the parent. In imperative languages, it is trivial to do. For example, in Java: public class A { private List<B> m_children = new LinkedList<B>(); private boolean m_valid = true; public void invalidate() { m_valid = false; } public void addChild(B child) { m_children.add(child); child.m_parent = this; } } public class B { public A m_parent = null; private int m_data = 0; public void setData(int data) { m_data = 0; m_parent.invalidate(); } } public class Main { public static void main(String[] args) { A a = new A(); B b = new B(); b.setData(0); //invalidates A } } How do I do the above in Haskell? I cannot wrap my mind around this, since once I construct an object in Haskell, it cannot be changed. I would be much obliged if the relevant Haskell code is posted.

    Read the article

  • Multi threading question..

    - by dotnet-practitioner
    I would like to invoke heavy duty method dowork on a separate thread and kill it if its taking longer than 3 seconds. Is there any problem with the following code? class Class1 { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main(string[] args) { Console.WriteLine("starting new thread"); Thread t = new Thread(new ThreadStart(dowork)); t.Start(); DateTime start = DateTime.Now; TimeSpan span = DateTime.Now.Subtract(start); bool wait = true; while (wait == true) { if (span.Seconds > 3) { t.Abort(); wait = false; } span = DateTime.Now.Subtract(start); } Console.WriteLine("ending new thread after seconds = {0}", span.Seconds); Console.WriteLine("all done"); Console.ReadLine(); } static void dowork() { Console.WriteLine("doing heavy work inside hello"); Thread.Sleep(7000); Console.WriteLine("*** finished**** doing heavy work inside hello"); } }

    Read the article

  • longest increasing subsequent

    - by davit-datuashvili
    i have write this code is it correct? public class subsequent{ public static void main(String[] args){ int a[]=new int[]{0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15}; int a_b[]=new int[a.length]; a_b[0]=1; int int_max=0; int int_index=0; for (int i=0;i<a.length;i++){ for (int j=0;j<i;j++){ if (a[i]>a[j] && a_b[i]<(a_b[j]+1)){ a_b[i]=a_b[j]+1; } } if (a_b[i]>int_max){ int_max=a_b[i]; int_index=i; } } int k=int_max+1; int list[]=new int[k]; for (int i=int_index;i>0;i--){ if (a_b[i]==k-1){ list[k-1]=a[i]; k=a_b[i]; } } for (int g=0;g<list.length;g++){ System.out.println(list[g]); } } }

    Read the article

  • Java: Efficient Equivalent to Removing while Iterating a Collection

    - by Claudiu
    Hello everyone. We all know you can't do this: for (Object i : l) if (condition(i)) l.remove(i); ConcurrentModificationException etc... this apparently works sometimes, but not always. Here's some specific code: public static void main(String[] args) { Collection<Integer> l = new ArrayList<Integer>(); for (int i=0; i < 10; ++i) { l.add(new Integer(4)); l.add(new Integer(5)); l.add(new Integer(6)); } for (Integer i : l) { if (i.intValue() == 5) l.remove(i); } System.out.println(l); } This, of course, results in: Exception in thread "main" java.util.ConcurrentModificationException ...even though multiple threads aren't doing it... Anyway. What's the best solution to this problem? "Best" here means most time and space efficient (I realize you can't always have both!) I'm also using an arbitrary Collection here, not necessarily an ArrayList, so you can't rely on get.

    Read the article

  • How do i set this window to topmost?

    - by acidzombie24
    How do i set my window above all other? I need a bad but noticeable msg box that closes on its own. Msg is a dummy form which is empty. All i want is its title. The problems with the code is the window isnt created 0,0 (its just whereever windows feels like putting it). The width is correct but i notice if i click firefox or another app window my app doesnt pop up. I know it is being shown bc i can see it in the taskbar at the bottom for a brief second. So the bugs so far Doesnt go topmost if i click another app Isnt 0,0 How do i fix this? { var msg = new Msg(); msg.Text = (has ? "*" : "+") + args[0]; msg.TopMost = true; msg.Width = 2000; msg.Top = 0; msg.Left = 0; msg.Show(); System.Threading.Thread.Sleep(1000); msg.Close(); }

    Read the article

  • Counting substring, while loop

    - by user1554786
    public class SubstringCount { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.println("Enter a word longer than 4 characters, and press q to quit"); int count = 0; while (scan.hasNextLine()) { System.out.println("Enter a word longer than 4 characters, and press q to quit"); String word = scan.next(); if (word.substring(0,4).equals("Stir")) { count++; System.out.println("Enter a word longer than 4 characters, and press q to quit"); scan.next(); } else if (word.equals("q")) { System.out.println("You have " + count + ("words with 'Stir' in them")); } else if (!word.substring(0,4).equals("Stir")) { System.out.println("Enter a word longer than 4 characters, and press q to quit"); scan.next(); } } } } Here I need to print how many words entered by the user contain the substring 'Stir.' However I'm not sure how to get this to work, or if I've done any of it right in the first place! Thanks for any help!

    Read the article

  • Pass reference to ArrayLists to a method.

    - by bhavna raghuvanshi
    here is the whole program: public class ListMerge { public static void main( String[] args) { Scanner input = new Scanner(System.in); System.out.println ("Input length of arraylist 1:"); int n = input.nextInt(); ArrayList x = new ArrayList(); ArrayList y = new ArrayList(); for (int i = 0; i < n; i++) { System.out.println ("Input x[ " + i +"] :" ); x.add(new Integer(i)); } System.out.println ("Input length of arraylist 2:"); int m = input.nextInt(); for (int i = 0; i < m; i++) { System.out.println ("Input y[ " + i +"] :" ); y.add(new Integer(i)); } } list int merge(ArrayList x, ArrayList y) { List all = new ArrayList(); all.addAll(x); all.addAll(y); System.out.println(all); return all; } } also tell me how do i call the function merge?

    Read the article

  • how to merge two ordered list of objects?

    - by bhavna raghuvanshi
    public class ListMerge { public static void main( String[] args) { Scanner input = new Scanner(System.in); System.out.println ("Input length of arraylist 1:"); int n = input.nextInt(); ArrayList x = new ArrayList(); ArrayList y = new ArrayList(); for (int i = 0; i < n; i++) { System.out.println ("Input x[ " + i +"] :" ); x.add(new Integer(i)); } System.out.println ("Input length of arraylist 2:"); int m = input.nextInt(); for (int i = 0; i < m; i++) { System.out.println ("Input y[ " + i +"] :" ); y.add(new Integer(i)); } List<Integer> all = new ArrayList<Integer>(); all.addAll(x); all.addAll(y); System.out.println(all); } } I did this but its not taking values from user. pls tell me why....

    Read the article

  • java threads don't see shared boolean changes

    - by andymur
    Here the code class Aux implements Runnable { private Boolean isOn = false; private String statusMessage; private final Object lock; public Aux(String message, Object lock) { this.lock = lock; this.statusMessage = message; } @Override public void run() { for (;;) { synchronized (lock) { if (isOn && "left".equals(this.statusMessage)) { isOn = false; System.out.println(statusMessage); } else if (!isOn && "right".equals(this.statusMessage)) { isOn = true; System.out.println(statusMessage); } if ("left".equals(this.statusMessage)) { System.out.println("left " + isOn); } } } } } public class Question { public static void main(String [] args) { Object lock = new Object(); new Thread(new Aux("left", lock)).start(); new Thread(new Aux("right", lock)).start(); } } In this code I expect to see: left, right, left right and so on, but when Thread with "left" message changes isOn to false, Thread with "right" message don't see it and I get ("right true" and "left false" console messages), left thread don't get isOn in true, but right Thread can't change it cause it always see old isOn value (true). When i add volatile modifier to isOn nothing changes, but if I change isOn to some class with boolean field and change this field then threads are see changes and it works fine Thanks in advance.

    Read the article

  • Iterating over a String to check for a number and printing out the String value if it doesn't have a number

    - by wheelerlc64
    I have set up my function for checking for a number in a String, and printing out that String if it has no numbers, and putting up an error message if it does. Here is my code: public class NumberFunction { public boolean containsNbr(String str) { boolean containsNbr = false; if(str != null && !str.isEmpty()) { for(char c : str.toCharArray()) { if(containsNbr = Character.isDigit(c)) { System.out.println("Can't contain numbers in the word."); break; } else { System.out.println(str); } } } return containsNbr; } } import com.imports.validationexample.function.NumberFunction; public class Main { public static void main(String[] args) { NumberFunction nf = new NumberFunction(); System.out.println(nf.containsNbr("bill4")); } } I am trying to get it to print out the result to the console, but the result keeps printing multiple times and prints the boolean value, which I do not want, something like this: bill4 bill4 bill4 bill4 Can't contain numbers in the word. true Why is this happening? I've tried casting but that hasn't worked out either. Any help would be much appreciated.

    Read the article

  • Java Socket Closes After Connection?

    - by Matthew
    Why does this port/socket close once a connection has been made by a client? package app; import java.io.*; import java.net.*; public class socketServer { public static void main(String[] args) { int port = 3333; boolean socketBindedToPort = false; try { ServerSocket ServerSocketPort = new ServerSocket(port); System.out.println("SocketServer Set Up on Port: " + port); socketBindedToPort = true; if(socketBindedToPort == true) { Socket clientSocket = null; try { clientSocket = ServerSocketPort.accept();//This method blocks until a socket connection has been made to this port. System.out.println("Waiting for client connection on port:" + port); /** THE CLIENT HAS MADE A CONNECTION **/ System.out.println("CLIENT IS CONENCTED"); } catch (IOException e) { System.out.println("Accept failed: " + port); System.exit(-1); } } else { System.out.println("Socket did not bind to the port:" + port); } } catch(IOException e) { System.out.println("Could not listen on port: " + port); System.exit(-1); } } }

    Read the article

  • question about permut-by-sorting

    - by davit-datuashvili
    hi i have following question from book introduction in algorithms second edition there is such problem suppose we have some array A int a[]={1,2,3,4} and we have some random priorities array P={36,3,97,19} we shoud permut array a randomly using this priorities array here is pseudo code P ERMUTE -B Y-S ORTING ( A) 1 n ? length[A] 2 for i ? 1 to n do P[i] = R ANDOM(1, n 3 ) 3 4 sort A, using P as sort keys 5 return A and result will be permuted array B={2, 4, 1, 3}; please help any ideas i have done this code and need aideas how continue import java.util.*; public class Permut { public static void main(String[]args){ Random r=new Random(); int a[]=new int[]{1,2,3,4}; int n=a.length; int b[]=new int[a.length]; int p[]=new int[a.length]; for (int i=0;i<p.length;i++){ p[i]=r.nextInt(n*n*n)+1; } // for (int i=0;i<p.length;i++){ // System.out.println(p[i]); //} } } please help

    Read the article

  • Classes in same package

    - by nicholas_r
    I love the Intellij IDEA but i have been stacked on one little problem with Java imports. So for example there is a package with name "example" and two different classes in it: A.java and B.java. And i wanna get access to class "A" from class "B" without imports. Like this: class A: package example; public class A{ ... some stuff here ...} class B: package example; public class B{ public static void main(String[] args){ A myVar = 1234; } } This code may not work, but it's doesn't matter. Trouble just with IDE and with its mechanism of importing classes. So, problem is that i can't see A class from B. Idea says 'Cant resolve symbol' but i actually know that class A exists in package. Next strange is that complier works fine and there are no exceptions. Just IDEA can't see the class in the same package. Does anybody has any ideas?

    Read the article

  • directory traversal in Java using different regular and enhanced for loops

    - by user3245621
    I have this code to print out all directories and files. I tried to use recursive method call in for loop. With enhanced for loop, the code prints out all the directories and files correctly. But with regular for loop, the code does not work. I am puzzled by the difference between regular and enhanced for loops. public class FileCopy { private File[] childFiles = null; public static void main(String[] args) { FileCopy fileCopy = new FileCopy(); File srcFile = new File("c:\\temp"); fileCopy.copyTree(srcFile); } public void copyTree(File file){ if(file.isDirectory()){ System.out.println(file + " is a directory. "); childFiles = file.listFiles(); /*for(int j=0; j<childFiles.length; j++){ copyTree(childFiles[j]); } This part is not working*/ for(File a: childFiles){ copyTree(a); } return; } else{ System.out.println(file + " is a file. "); return; } } }

    Read the article

< Previous Page | 114 115 116 117 118 119 120 121 122 123 124 125  | Next Page >