Use of wildcard(*) in import statement
I am a bit new in Actionscript 3.0 and I love to learn it.
I saw the following two import statements in an actionscript 3.0 code.
import flash.display.MovieClip;
import flash.display.SimpleButton;
In this case, can I use just juse * sign as in import.flash.display.*; ???
Is this change would cause any problem?
Sami
There are cases when it works and cases when it doesn't, and I don't know if there is a reason. You can try and see if it makes a difference, and if you get error regarding lack of definition you can hopefully determine that you need to explicitly name the class.
Also, it partly depends on where you are implementing the code. Usually when coding in the Actions panel you do not need to import most classes at all. But when you are working with class files you normally have to import any that are not top-level, such as the two you identified.
Similar Messages
-
Which one better to use - jsp:useBean or import statement
Hi,
I just want to know that which one is better to use jsp:useBean or import statement .
I can instantiate and call method of myclass -
1) by importing the class through import tag in jsp as <%@page import="myclass"%. or
2). by using <jsp:useBean tag....
i have these two option to do the same thing. i know that basically useBean is used to call setter and getter method of bean class and but it can be used to call a normal java file that have some logic .
so what should i used , which one is better and why?
useBean provides scope and object instance so no need to create object by new operator. and with import you have to create an instance .
but which tag should i use in my jsp?
i am confused???ok, means i can use jsp:useBean tag for all my
classes that are not actually bean. so it will be
instantiated at run time and provide efficiency .No. Jsp:useBean is used for java bean components.
>
but when should i use import statement in my jsp and
it happen at translation time so will it create any
type of burden for my code if i import multiple
classes.For non-java beans, you need to import the classes, period.
It's not a burden, it's a necessity. -
Using wildcards in import statement
I typically use wildcards in my import statements. For example:
import javax.swing.*;
Are there any advantages, though, in specifying exactly which classes I am importing?
For example,
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JEditorPane;
import java.swing.JProgressBar;
// etc.
Specigically, is the resulting class file any smaller if I specify exactly which classes to use and does the Java runtime engine load faster if I specify exactly which classes I use in the import statemetents?
Thanks,Import has precisely zero runtime impact. I believe it is used to help locate the specified class at runtime. Take the following 2 simple source files:
import java.util.Vector;
//import java.util.*;
public class VectorTest
public static void main( String[] args )
Vector v = new Vector();
v.add("Item 1");
v.add("Item 2");
System.out.println( v.get(1) );
public class Vector
public boolean add(Object o)
return true;
public Object get(int index)
return "doh!";
}1) Run the code as is and "Item 2" is displayed
2) Recompile the code using the generic import and "doh!" is displayed.
The point is that by fully qualifying the import statement you are sure you are executing the correct class and not just some class that happens to be lying around somewhere in your classpath. -
Use of wildcard * in SELECT statement
I have read that the use of the wildcard * in a SELECT statement cannot be utilized when using the INSERT INTO or other queries where data column/field alignment is critical. I have noted that the INSERT INTO column/fields must be in the same order
as the SELECT statement (as there is no alignment to column/field names). Can someone please provide me with the information or article that covered this scenario?It is consider a good practice to specify columns name, however , SQL Server is smart enough to insert the data without too , but only if the table does not have an IDENTITY property
CREATE TABLE #t (c1 int, c2 char(1),c3 real, c4 bit)
CREATE TABLE #t1 (c1 int, c2 char(1),c3 real, c4 bit)
---Same thing with INSERT like SELECT * you asked
INSERT INTO #t1 VALUES (1,'A',2.5,0)
INSERT INTO #t1 VALUES (2,'B',3.5,1)
INSERT INTO #t1 VALUES (3,'C',4.5,0)
INSERT INTO #t SELECT * FROM #t1
SELECT * FROM #t
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
what's the difference between
import java.util.Vector;
and
import java.util.*;
is there any difference in bytecode generated? or time takes to compile?
what's the best practice?Yes there is a best practice, it's the one you mentioned. Use the more specific import statement. If you're only using one or two classes from a package, explicitly name them in the import statements. That way somebody else reading your code (which includes yourself, six months later) can immediately get a better understanding of your code.
If this rule is followed, and you see this as the first line of a source file:
import java.util.StringTokenizer;
then you know the StringTokenizer is being used. But if you saw this:
import java.util.*;
you wouldn't know which one is being used until you're deep in the code.
Knowing right away whether a class is tokening a string, versus say using collections, makes it a lot easier to read.
You should only use the whole-package include if you're importing a really big part of the package. For example:
import java.awt.*;
is probably OK because it's relatively unlikely a person will use only a couple classes from that package. -
Using wildcard in If statement
Hi. I have 2 part numbers I'm trying to find and I just want to display the text below on these 2 parts only. The 2 part numbers are:
PL-PLCC44-S-01TR
PL-PLCC68-S-01TR
This is not on a search page, so the Like command does not work.I created this If statement and when I put the whole part number in the quotes, it works fine, but I want to use a wildcard since there will be more parts like this and I will not want to keep adding parts to this If statement.So basically, I'm trying to search for all the part numbers that end in TR. If they do, display the text below on the page. How can I use these wilcards correctly?
<cfif ThisPart.Client_SKU EQ "%TR">Min. buy of 50pcs is required.</cfif>
Thanks.
AndyHere's the answer:
<cfif right(ThisPart.Client_SKU, 2) EQ "TR">Min. buy of 50pcs is required.</cfif> -
Hi,
I understand that in order to access the methods of a different class, I can "import" it. Here is my question though:
Where am I importing it from? I mean, surely if I am importing a class from e.g. the Java.util package, doesn't this package need to be on my computer somewhere?
And also, if I make a .jar file of my application for use on another computer and the files contain import statements, doesn't the other computer need to have these packages on their machine?
I know this seems like a silly question but it's bothering me!
GFYep, you can unzip them to see inside. The package name unzips into a directory structure and the Class name is a file. So java.util.HashMap will unzip into a directory java/util and have a file called HashMap.class in it.
You can usually download the source code for these classes also. -
Using imported archive in UDF using import statement
Hello Expert,
I am trying to use the class of keystore_api.jar which is impoted in imported archive in my UDF using the import statement
com.sap.engine.interfaces.keystore.KeystoreManager but I am getting the error
package com.sap.engine.interfaces.keystore does not exist
import com.sap.engine.interfaces.keystore.*;
Appreciate your valuable replies.
Kind Regards,
Kubra fatimaHi,
as ur import statement states
com.sap.engine.interfaces.keystore
You need to import the jar in directory hierarchy as above manner.
com[sap[engine[interface[]keystore[JAR]]]]
Regards
Ashu -
When is necessary to use import statements to import classes?
Hi,
I'm sure that it must be necessary to use import statements
in some situations, I'm finding that my code often works fine
without them. For example, some instructions will say it is
necessary to use import.flash.events.MouseEvent; before
MouseEvent.CLICK will work, or that I must import the loader class
before loading an SWF, but I'm finding that I can skip timporting
and it works fine. Could anyone please explain why this it, and
give me some idea of how to knew when to import and when I don't
have to?
Thank you in advance!Importing is only necessary when you create you own classes
or are using a class that Flash doesn't auto import such as the
fscommand package. Any time you create your own custom
package/class, it is also necessary to use import statements unless
you add the folder containing your custom packages to the default
class path. -
Import Statement - Which is Better ???
Which import statement is better? Are there any performance advantages of calling the ones you need explicitly instead of using the shorthand (.*)?
import java.util.*
or
import java.util.Vector;
import java.util.TreeMap;there is no runtime performance difference. There could be a difference in compliation time if you use wildcards, but even that difference would probably be insignificant (plus, is compile time usually a concern in java?). The main advantage to importing only the classes you need, as the previous poster pointed out, is to reduce compilation ambiguities (e.g. does 'Date' refer to java.sql.Date or java.util.Date). For example, a recent poster just reported a problem where he imported java.beans.* and java.sql.* and, after upgrading to 1.4, none of his code compiles because both packages now have a Statement class, which causes ambiguities. As a general rule, it is best to import only the classes you need.
-
Some questions on import statements.
When I see
import java.awt.*
import java.awt.event.*
am I on track interpreting this to mean that you want to be able to use any of the classes found in package java.awt?
why would import java.awt.event.* be necessary if event is a class in the java.awt.* package you're importing in the second import statement up above?
does * mean like a "wildcard" which allows you to utilize
anything that is part of java.awt?It allows you to use any of the classes in that directory, but not any classes in sub-directories of that directory.
-
Import statements disappearing in FB3
I am trying create an actionscript file in Flex Builder 3 and
I noticed that after I put in all my imports and I start declaring
variables, most of my import statements will just disappear. I did
some searching on the net and heard some people mention about using
wildcards in there import statements, but I am not using any
wildcards. Is this a function of Flex Builder and if so, how do I
turn it off?Hi,
You can turn it off. Go to
Window -> Preferences... -> Flex -> Editors ->
ActionScript Code
deselect the check box for "Remove unused imports while
organizing"
Hope this helps. -
Hi srinivas bobbala,
Thank you for your response.But I think my quesition was not clear.My ques... is for suppose there is one datafile for importing like.. "datafile_21" Here my intention is it takes file from datafile_21 only but it appears in import statement like datafile_21<<curmon>>.
import database sample.sample data from data_file "c:\\ABC\datafile_21_AUG.txt" using server rules_file datafile on error abort;
In this it takes datafile from datafile_21.But it appears like datafile_21_AUG in import statement.This AUG coming from batch file.
Essmsh c:\\ABC\loadmxl.mxl %curmon%No it is not possible.
I assume the data file "datafile_21" is first renamed to datafile_21_${CurrMth} in the batchscript.
After that this data file *datafile_21_${CurrMth}* is pointed in the import statement.
In the logs you will see this file as datafile_21_Aug. -
Import Statement Different ways to refer ???
Dear Friends,
Can any one help me the difference between the usage of import statement....
1. using import statement
2. using the class directly
that is,
for example ;
1. import java.util.Date;
Date dt = new Date();
2. java.util.Date dt = new java.util.Date();
what's the difference between two reference of Date class...is there any meaning beyond this ?????
Regards,
V.Prasannawhat's the difference between two reference of Date
class...is there any meaning beyond this ?????there is no difference once the code is compiled - the compiler resolves single class names to their fully-qualified names (ie with the package prefix) and that appears in the .class file constant pool
before compilation then my opinion is that having all the imports at the top of the file is good practice because you can see what is being used easily -
IMPORT Statement Issue (Internal Table)
Hi All,
I am using an IMPORT statement to get all the data from other report's internal table. Now whenever this (the other report's internal table) is changed (for field addition, etc), my report throws a dump. Hence, everytime I have to add these fields in my program as well.
Is there any way by which I can include the whole internal table of that report in my program just like
'INCLUDE STRUCTURE VBRK'.
Thanks in advanceHi, CHeck this code related to your problem..This will helpful to you...
I have done this program earlier..I hope it will helpful to u..
This programa calling the other program to import the data..
Check it out...
*" Tables declarations.................................................
TABLES:
spfli.
*" Type declarations...................................................
Type declaration of the structure to hold data from table SPFLI *
TYPES:
BEGIN OF type_s_spfli,
carrid LIKE spfli-carrid, " Carrier Id
connid LIKE spfli-connid, " Connection Number
cityfrom LIKE spfli-cityfrom, " City from
cityto LIKE spfli-cityto, " City to
airpfrom LIKE spfli-airpfrom, " Airport from
airpto LIKE spfli-airpto, " Airport to
countryfr LIKE spfli-countryfr, " Country from
countryto LIKE spfli-countryto, " Country to
END OF type_s_spfli.
Data Declaration...................................................*
Field String To Hold Flight Details Record from SPFLI *
DATA
fs_spfli TYPE type_s_spfli.
Data Declaration...................................................*
Internal Table To Hold Flight Details Records from SPFLI *
DATA
t_spfli LIKE STANDARD TABLE OF fs_spfli.
TYPES:
BEGIN OF types_s_itab,
carrid LIKE sflight-carrid, " Carrier id
connid LIKE sflight-connid, " Connection number
fldate LIKE sflight-fldate, " Flight date
END OF types_s_itab.
Data Declaration...................................................*
Field String To Hold Flight Details Record from SFLIGHT *
DATA
fs_itab TYPE types_s_itab.
Data Declaration...................................................*
Internal Table To Hold Flight Details Records from SFLIGHT *
DATA
t_itab LIKE STANDARD TABLE OF fs_itab.
*" Type declarations...................................................
Type declaration of the structure to hold data from table SBOOK *
TYPES:
BEGIN OF type_s_sbook,
carrid LIKE sbook-carrid, " Carrier Id
connid LIKE sbook-connid, " Connection Number
fldate LIKE sbook-fldate, " Flight date
bookid LIKE sbook-bookid, " Booking number
loccuram LIKE sbook-loccuram, " Local currency
loccurkey LIKE sbook-loccurkey,
order_date LIKE sbook-order_date, " Booking date
END OF type_s_sbook.
Data Declaration...................................................*
Field String To Hold Flight Details Record from BOOK *
DATA
fs_sbook TYPE type_s_sbook.
Data Declaration...................................................*
Internal Table To Hold Flight Details Records from SBOOK *
DATA
t_sbook LIKE STANDARD TABLE OF fs_sbook.
DATA
w_checkbox. " Checkbox
SELECT-OPTIONS:
s_carr FOR spfli-carrid. " Carrier id range
START-OF-SELECTION EVENT *
START-OF-SELECTION.
PERFORM selectq.
END-OF-SELECTION EVENT *
END-OF-SELECTION.
SET PF-STATUS 'YH1314_030502'.
PERFORM display_basic.
AT USER-COMMAND.
PERFORM ucomm.
*& Form selectq
This subroutine retreive data from SPFLI table
There are no interface parameters to be passed to this subroutine.
FORM selectq .
SELECT carrid " Carrier id
connid " Connection number
cityfrom " City from
cityto " City to
airpfrom " Airport from
airpto " Airport to
countryfr " Country from
countryto " Country to
INTO CORRESPONDING FIELDS OF TABLE t_spfli
FROM spfli
WHERE carrid IN s_carr.
ENDFORM. " Selectq
*& Form display_basic
This subroutine displays data from internal table
There are no interface parameters to be passed to this subroutine.
FORM display_basic .
LOOP AT t_spfli INTO fs_spfli.
WRITE:
/ w_checkbox AS CHECKBOX,
fs_spfli-carrid,
fs_spfli-connid,
fs_spfli-cityfrom,
fs_spfli-cityto,
fs_spfli-airpfrom,
fs_spfli-airpto,
fs_spfli-countryfr,
fs_spfli-countryto.
ENDLOOP. " LOOP AT T-SPFLI INTO...
ENDFORM. " Display_basic
*& Form UCOMM
This subroutine for at user-command event
There are no interface parameters to be passed to this subroutine.
FORM ucomm .
RANGES :
r_carr FOR spfli-carrid,
r_conn FOR spfli-connid,
r_carrid FOR sflight-carrid,
r_connid FOR sflight-connid,
r_fldate FOR sflight-fldate.
CASE sy-ucomm.
WHEN 'DISPLAY'.
DATA:
lw_lines TYPE i,
lw_lineno TYPE i VALUE 3.
DESCRIBE TABLE t_spfli LINES lw_lines.
DO lw_lines TIMES.
READ LINE lw_lineno FIELD
VALUE w_checkbox INTO w_checkbox
fs_spfli-carrid INTO fs_spfli-carrid
fs_spfli-connid INTO fs_spfli-connid.
IF sy-subrc = 0.
IF w_checkbox = 'X'.
r_carr-sign = 'I'.
r_carr-option = 'EQ'.
r_carr-low = fs_spfli-carrid.
APPEND r_carr.
r_conn-sign = 'I'.
r_conn-option = 'EQ'.
r_conn-low = fs_spfli-connid.
APPEND r_conn.
ENDIF. " IF W_CHECKBOX = 'X'
ENDIF. " IF SY-SUBRC = 0
ADD 1 TO lw_lineno.
ENDDO. " DO LW_LINES TIMES
SUBMIT yh1314_030502_call
WITH s_carr IN r_carr
WITH s_conn IN r_conn
AND RETURN.
IMPORT t_itab FROM MEMORY ID 'YH1314'.
LOOP AT t_itab INTO fs_itab.
r_carrid-sign = 'I'.
r_carrid-option = 'EQ'.
r_carrid-low = fs_itab-carrid.
APPEND r_carrid.
r_connid-sign = 'I'.
r_connid-option = 'EQ'.
r_connid-low = fs_itab-connid.
APPEND r_connid.
r_fldate-sign = 'I'.
r_fldate-option = 'EQ'.
r_fldate-low = fs_itab-fldate.
APPEND r_fldate.
ENDLOOP. " LOOP AT T_ITAB INTO.....
SELECT carrid " Carriee Id
connid " Connection number
fldate " Flight date
bookid " Booking number
loccuram " Local Currency
order_date " Booking date
INTO CORRESPONDING FIELDS OF TABLE t_sbook
FROM sbook
WHERE carrid IN r_carrid AND
connid IN r_connid AND
fldate IN r_fldate.
IF SY-SUBRC NE 0.
MESSAGE 'NO RECORDS FOUND'(006) TYPE 'S'.
ENDIF. " IF SY-SUBRC NE 0
LOOP AT t_sbook INTO fs_sbook.
AT FIRST.
WRITE: /5 'Carrier Id'(001),
20 'Conn Id'(002),
35 'Flight date'(003),
50 'Book Id'(004),
65 'Local Currency'(005).
ENDAT. " AT FIRST
WRITE: /5 fs_sbook-carrid,
20 fs_sbook-connid,
35 fs_sbook-fldate,
50 fs_sbook-bookid,
65 fs_sbook-loccuram CURRENCY fs_sbook-loccurkey.
ENDLOOP. " LOOP AT T_SBOOK INTO.....
ENDCASE. " CASE SY-UCOMM
ENDFORM. " UCOMM
Regards
Kiran
Maybe you are looking for
-
HP office jet 8600 model N911g
My wife purchased new, first installed 2014-02-26. OS win XP Pro, wireless ok. Printer working fine untill wife did not remove set up cartridges after installation completed. Printer was working w/set up catridges untill black ink ran low and was r
-
Information Broadcasting - Creation - Error in HTML / MHTML format
Hi gurus, I'm trying to create a Broadcasting for a query with HTML format. All the steps, including the scheduling, were succesfully. But when I click on Execute button, I got the following error message: The following error text was processed in th
-
MDI form feature in JDeveloper 10.1.3
It's nice to see that you provide MDI form feature now for JClient in JDeveloper 10.1.3. Actually, you are having an even more powerful rich client framework that is quite more useful than MDI, witch is already available in your inventory. That is th
-
Changes not reflected in Change to Document (tcode CRMD_ORDER)
Hello Expert, I made a change in field 'Planned Completion Date', in my transaction through tcode CRMD_ORDER. When I view Change to Document (CRMD_ORDER > top menu > Extras > Change Documents), the change is not reflected. All changes are usually cap
-
Partition Pruning vs Partition-Wise Join
Hi, I am not sure if this is the right place for this question, but here it goes. I am in a situation where in the begining I have to join two big tables without any where clauses. It is pretty much a Caretsian Product where a criteria meets (Interna