Search Results

Search found 33640 results on 1346 pages for 'java generics'.

Page 171/1346 | < Previous Page | 167 168 169 170 171 172 173 174 175 176 177 178  | Next Page >

  • && (AND) and || (OR) in Java IF statements

    - by Azimuth
    My question might be very basic but still I think it worths to ask. I have the following code: if(!partialHits.get(req_nr).containsKey(z) || partialHits.get(req_nr).get(z) < tmpmap.get(z)){ partialHits.get(z).put(z, tmpmap.get(z)); } where partialHits is a HashMap. What will happen if the first statement is true? Will Java still check the second statement? Because in order the first statement to be true, the HashMap should not contain the given key, so if the second statement is checked, I will get NullPointerException. So in simple words, if we have the following code if(a && b) if(a || b) would Java check b if a is false in the first case and if a is true in the second case?

    Read the article

  • Java classpath and config file

    - by user1228291
    I'm having some trouble finding a config file with classpath. I use : InputStream stream = myclass.class.getResourceAsStream("properties.file"); The properties.file is located under config directory. When running the program with eclipse, it works. I just added config folder in the classpath in the launch configuration. But If I want to run the exported jar like this : java -jar -cp C:\project\lib;C:\project\config myclass.jar I get the oh wonderful java.lang.NullPointerException because it can't find the file. This sounds classic and stupid but I can't find a clue. What does eclipse do that I don't ? Thanks

    Read the article

  • Java date long value changed after insert, select query

    - by StackExploded
    AFAIK, java Date type is independent from Timezone which means that it represents specific moment of time as long typed value. I found really weird thing here. This is the original value i tried to insert. (http-0.0.0.0-9080-4) 1352955600000 <-- long integer. (http-0.0.0.0-9080-4) Thu Nov 15 00:00:00 EST 2012 <-- User Friendly Format. After i finished inserting into Oracle 11g database, the value has changed! (http-0.0.0.0-9080-4) 1352952000000 (http-0.0.0.0-9080-4) Wed Nov 14 23:00:00 EST 2012 How could this happen?? The more weird thing is it only happens specific environments such as Jboss. I'm currently using below environments. java 1.6 ibatis 2.34 jboss-5.1 (server) tomcat 6.0 (local) oracle 11g Is there anybody who can give me a clue or link to be helpful? it really bugging me!!

    Read the article

  • java.util.Observable, will clients complete executing their update() before continuing

    - by jax
    When I call: setChanged(); notifyObservers() on a java.until.Observable class, will all the listening Observer objects complete execution of their udpate() methods - assuming we are running in the same Thread - before the java.until.Observable class continues running? This is important because I will be sending a few messages through the notifyObservers(Object o) method in quick concession, it is important that each Observer class has finished its method before the new one though. I understand that the order of execution for each Observer class may vary when we call notifyObservers() - it is just important that the order of method execution for each individual instance is in order.

    Read the article

  • Java using enum with switch statement

    - by MisterSquonk
    I've looked at various Q&As on SO similar to this question but haven't found a solution. What I have is an enum which represents different ways to view a TV Guide... static enum guideView { GUIDE_VIEW_SEVEN_DAY, GUIDE_VIEW_NOW_SHOWING, GUIDE_VIEW_ALL_TIMESLOTS } ...when the user changes the view an event handler receives an int from 0-2 and I'd like to do something like this... // 'which' is an int from 0-2 switch (which) { case NDroid.guideView.GUIDE_VIEW_SEVEN_DAY: ... break; } I'm used to C# enums and select/case statements which would allow something like the above and I know Java does things differently but I just can't make sense of what I need to do. Am I going to have to resort to if statements? There will likely only ever be 3 choices so I could do it but I wondered how it could be done with switch-case in Java.

    Read the article

  • What is the differance between those two Strings in Java

    - by user1816808
    why when we declare string in java we can't use == to compare this string and always will turn to false while if we initialize the string from the beginning it will be true . for example : import java.util.Scanner; public class MyString { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner input = new Scanner(System.in); String s = input.nextLine(); if(s=="Hello") system.out.println("Hello"); String d = "Hello"; if(d=="Hello") system.out.println("Hello"); } } I need an explanation please ??

    Read the article

  • Java Util Linked List - how to find next?

    - by drozzy
    When using Java LinkedList how do you find out the element's next or previous relationships? I mean, in a regular linked list I would do something like this: Node node1 = new Node(); Node node2 = new Node(); LinkedList list = new LinkedList(); list.add(node1); list.add(node2); //then my node1 will know who it's next is: assertEquals(node2, node1.next()); But in Java's LinkedList, the data does not seem to be modified. So how do I actually find out who the "next" (or "previous" in the case of doubly-linked lists) element is?

    Read the article

  • for (Object object : list) [java] construction

    - by EugeneP
    My question, is, whether the sequence of elements picked from a list will always be the same, is this construction behaviour is deterministic for java "List"s - descendants of java.util.List 2) question, if I use for(Object o: list) construction and inside the loop's body increment a variable, will it be the index of list's elements? So, how it goes through list's elements, from 0 to size()-1 or chaotically? List.get(i) will always return this element? 3) question ( I suppose for the 2-nd question the answer will be negative, so:) for (int i=0; i < list.size(); i++) { } is the best way if I need to save the index of an element and later get it back from a list by its id?

    Read the article

  • Data Structure Brushup (Java)

    - by Daddy Warbox
    This should be easy for many of you, but for me it's just another bit of rust needing to be chipped away as I get back into basic Java coding. Using bloody associative arrays for so long in other languages have turned me nice and spoiled. :P My problem is simple: I'm storing a set of objects, each containing a string and a number, in a list. I would like each object inserted into this list to be sorted alphabetically by its string. I would also like to be able to retrieve objects from the list by their string as well. I would like to do this as formally and/or efficiently as possible. Is there something already available in the Java standard libraries for this?

    Read the article

  • Network license control for a Java application

    - by user1461615
    I have been tasked with providing some form of network license control for a Java application. The app would be stored on a network drive and run from a client machine. The basic idea is that it will be able to work out how many times it is being run concurrently and prevent the N+1th user from running the software where N is the number of concurrent licenses the customer has purchased. Is this possible somehow with a Java application? I implemented a "solution" which relied on multi-cast UDP communication between the running instances of the application but this didn't work because on most networks this kind of communication is blocked by security measures. Is there a better way? I don't even mind if it requires JNI/JNA. N.B. The solution does not have to be that sophisticated or highly secure.

    Read the article

< Previous Page | 167 168 169 170 171 172 173 174 175 176 177 178  | Next Page >